在更新Node.js和Socket.io之后,Socket.io的连接现在经常断开连接

我的服务已经更新到Node.js v6.9.4,现在Socket.io的连接频繁断开。
它没有在开发环境中复制,并决定恢复到更新之前的状态。

这个问题只与某些版本?
将更新到最新的Node.js解决这个问题?

谢谢您的合作。

  • 更新版本

    node.js@6.1.0 → 6.9.4 socket.io@1.4.6 → 1.7.2 # Client and server are the same version express@4.13.4 → 4.14.0 body-parser@1.15.1 → 1.15.2 jquery@2.2.3 → 3.1.1 jsdom@9.0.0 → 9.9.1 
  • 断开状态

    • 连接数约为200.(更新前的连接数约为20,000)
    • 连接1或2个小时后,连接断开。
    • Node.js服务器和负载均衡器(Pound)的CPU负载和内存使用情况没有exception。
    • 关于浏览器的日志(devtools)
      断开前请求(轮询)的响应时间为85秒,在下一个请求中输出“400错误请求”错误。 (正常状态下的响应时间为25秒)

       GET https://myapp.com/socket.io/?node...sport=polling.. 200 OK 24.99ms POST https://myapp.com/socket.io/?node...sport=polling.. 200 OK 1ms GET https://myapp.com/socket.io/?node...sport=polling.. 200 OK 25.01ms POST https://myapp.com/socket.io/?node...sport=polling.. 200 OK 0ms GET https://myapp.com/socket.io/?node...sport=polling.. 200 OK 1m 25s POST https://myapp.com/socket.io/?node...sport=polling.. 400 Bad Request.. ------ detail ------ NetworkError : 400 Bad Request - https://myapp.com/socket.io....... -------------- POST https://myapp.com/socket.io/?node...sport=polling.. 400 Bad Request.. ------ detail ------ NetworkError : 400 Bad Request - https://myapp.com/socket.io....... -------------- 
    • 关于服务器日志Node.js的日志中没有线索。 以下错误被输出到英镑日志,但因果关系是未知的。

       pound: (7f8592ce7700) e501 bad request "HQ" from xxx.xxx.xxx.xxx pound: (7f84cdbe5700) BackEnd yyy.yyy.yyy.yyy:9443 dead (killed) * "xxx.xxx.xxx.xxx" or "yyy.yyy.yyy.yyy" is the IP address. 
  • 基础设施信息

     Browser ─[ HTTPS ]─ Load balancer(Pound) ─[ HTTP ]─┬─ Node.js Server 1 ├─ Node.js Server 2 ├─ Node.js Server 3 └─ Node.js Server 4 
    • 浏览器和节点服务器之间的连接通过轮询来维护。 (不是WebSocket)
    • Node应用程序向另一个服务器发送HTTP请求
    • 负载平衡器
      • 操作系统:CentOS 6.6
      • 用于负载均衡的中间件:英镑ver.2.6
      • OS设置改变点:
        • 将最大可用进程数设置为100,000。
        • 将文件描述符的限制数量设置为100,000。
        • 将线程的内存映射限制设置为200,000。
        • 将最大线程数设置为100,000。
    • Node.js服务器
      • 操作系统:CentOS 6.6
      • OS设置改变点:
        • 将文件描述符的限制数设置为100,000
  • 连接代码

    • 服务器代码

       var socketApp = express(); ... var server = new serverBuilder({protcol: 'http', port: 9999}).getInstance(socketApp).listen(process.env.VMC_APP_PORT || 9999, function(){ }); var io = socketio.listen(server, {cookie: false}); io.use(function(socket, callback){ try { var hndReq = null; if (socket.handshake) { hndReq = socket.handshake; } if (!socket.handshake.query.param1) { socket.disconnect('unauthorized'); return; } ..... callback(); }); io.sockets.on("connection", function (socket) { try { var hndReq = null; if (socket.handshake) { hndReq = socket.handshake; } socket.on("disconnect", function () { .... }); } catch (e) { console.log(e); throw e; } }); 
    • 客户代码

       var query = 'param1=' + param1 + '&param2=' + param2; var socket = options.io.connect('https://myapp.com/socket.io/', {query:query, 'forceNew':true, reconnect:false}); socket.on("connect", function (data) { self._connected(); }); socket.on("disconnect", function (client) { socket.disconnect(); self._disconnected(); });