Bit*_*ian 1 long-polling websocket node.js socket.io
我是socket.io的新手.所以我的socket.io服务器sometimws崩溃给出以下错误
timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
Error: socket hang up
at createHangUpError (http.js:1360:15)
at ServerResponse.OutgoingMessage._writeRaw (http.js:507:26)
at ServerResponse.OutgoingMessage._send (http.js:476:15)
at ServerResponse.OutgoingMessage.write (http.js:749:16)
at XHRPolling.doWrite (E:\sitesroot\0\node_modules\socket.io\lib\transports\
xhr-polling.js:67:17)
at XHRPolling.HTTPPolling.write (E:\sitesroot\0\node_modules\socket.io\lib\t
ransports\http-polling.js:132:8)
at XHRPolling.Transport.packet (E:\sitesroot\0\node_modules\socket.io\lib\tr
ansport.js:515:15)
at Object.<anonymous> (E:\sitesroot\0\node_modules\socket.io\lib\transports\
http-polling.js:79:12)
at Timer.list.ontimeout (timers.js:101:19)
Run Code Online (Sandbox Code Playgroud)
它没有显示错误发生的位置或原因,因此非常确定它与我编写的代码无关.可能是运输的东西?我对此并不了解.任何关于如何阻止它崩溃的建议都将受到高度赞赏.谢谢
问题是@miktam说的.要解决此问题,您需要为代码添加错误侦听器.将此代码添加到您的应用程序:
//Error handler
process.on('uncaughtException', function (exception) {
// handle or ignore error
console.log(exception);
});
Run Code Online (Sandbox Code Playgroud)
如果出现错误,它将调试它而不是崩溃它.我有完全相同的问题,这解决了它.
| 归档时间: |
|
| 查看次数: |
3224 次 |
| 最近记录: |