我正在8081端口上运行一个SSL套接字。虽然在Apache2.4上完美运行,但在IIS上一段时间后,socket.io会崩溃并显示ECONNRESET错误,这在Apache中从未发生过。我的socket.io版本是1.3.7。IIS是v10(Windows Server 2016)。
我已经按建议添加了一些错误处理,但无法解决问题。以下是经过清理的代码。
但我不知道它与我的代码有多少关联,甚至不知道应该把它放在哪里! 这是错误的详细信息。
我已经按建议添加了一些错误处理,但无法解决问题。以下是经过清理的代码。
var options = {
key: fs.readFileSync('example.key'),
cert: fs.readFileSync('example.cert'),
ca: fs.readFileSync('example.inter')
};
var app = require('https').createServer(options),
io = require('socket.io').listen(app);
io.set('origins', '*:8081');
app.on('error', function(error){
console.log('error', error);
});
app.listen(8081);
io.sockets.on('connection', function(__socket) {
__socket.on('error', function(){
__socket.destroy();
});
__socket.on('disconnect', function(){
__socket.destroy();
});
}
我读到,你可以通过添加密码来修复这个问题。
ciphers: 'DES-CBC3-SHA'
但我不知道它与我的代码有多少关联,甚至不知道应该把它放在哪里! 这是错误的详细信息。
{ Error: socket hang up
at createHangUpError (_http_client.js:253:15)
at Socket.socketCloseListener (_http_client.js:285:23)
at emitOne (events.js:101:20)
at Socket.emit (events.js:188:7)
at TCP._handle.close [as _onclose] (net.js:497:12) code: 'ECONNRESET' }
编辑:已更新至最新版本(2.0.3),但仍存在问题。
编辑2:使用io.emit时似乎会发生ECONNERESET,这很奇怪,因为它感觉像是在未先验证套接字是否仍然连接的情况下尝试进行发射...