我的网站运行良好,但是我需要安装SSL认证。 安装SSL后,我的控制台显示“ net :: ERR_CONNECTION_CLOSED”。
节点文件的一部分。
function load() {
query('SET NAMES utf8');
query('sql query was here', function(err, row) {
if((err) || (!row.length)) {
process.exit(0);
return;
}
currentid = row[0].id;
});
loadHistory();
setTimeout(function() { io.listen(8080); }, 3000);
}
部分客户端脚本
function connect() {
if(!SOCKET) {
chat("italic", "Generating token...");
var hash = getCookie('hash');
if(!hash) {
chat("italic", "Please, sing through steam.");
} else {
chat("italic", "Connecting...");
SOCKET = io(HOST);
SOCKET.on('connect', function(msg) {
chat("italic", "Connected!");
SOCKET.emit('hash', hash);
});
SOCKET.on('connect_error', function(msg) {
chat("italic", "Conection lost...");
});
SOCKET.on('message', function(msg) {
onMessage(msg);
});
}
} else {
console.log("Error: connection already exists.");
}
}