当客户端仍在加载页面时刷新时,Node一直不停地退出我(因此套接字被终止,而我仍在处理请求)。错误:
[ERROR] - Error: socket hang up at createHangUpError (http.js:1472:15) at Socket.socketCloseListener (http.js:1522:23) at Socket.EventEmitter.emit (events.js:95:17) at TCP.close (net.js:465:12) (at lib/Maintenance.js:38)
我尝试附加on('error', ...到:
on('error', ...
req
listen
get
use
post
但是,我似乎无法捕捉到该错误。它仍然被抛出,我的错误处理程序都没有反应。我可能会缺少什么?
将错误侦听器附加到套接字对象
app.use(function(req, res, next) { req.socket.on("error", function() { }); res.socket.on("error", function() { }); next(); });