【问题标题】:Node/Redis/Socket/pm2 Server closes connection after ~11 hoursNode/Redis/Socket/pm2 服务器在约 11 小时后关闭连接
【发布时间】:2017-06-24 09:32:45
【问题描述】:

我的 node/nginx/redis/socket/pm2 服务器有问题。它似乎只是因为 mysql 节点包引发的错误而失败。

因为我在uncaughtExceptionSIGTERM 上使用process.exit(0),PM2 会自动重新启动它。

问题仍然是它显然无缘无故地死了,服务器没有遇到负载,内存使用量没有飙升。

我现在很迷茫,我已经查看了其他解决方案并在昨晚实施了一些解决方案,但今天早上 4 点仍然抛出错误。

"socket = 1 disconnect\n... user disconnected | Number of connections remaining: 1\n",

Redis 在启动时显示两个警告,否则我的日志文件为空

    14718:M 06 Feb 17:57:38.107 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
14718:M 06 Feb 17:57:38.107 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

pm2 在其日志中报告以下问题:

Error: Connection lost: The server closed the connection.
at Protocol.end (/usr/___/___/app/node_modules/mysql/lib/protocol/Protocol.js:109:13)
at Socket.<anonymous> (/usr/___/___/app/node_modules/mysql/lib/Connection.js:109:28)
at emitNone (events.js:91:20)
at Socket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

【问题讨论】:

    标签: mysql node.js sockets nginx


    【解决方案1】:

    如果有人遇到这个问题,

    我能够追踪到问题是 100% 由 mysql 节点模块引起的。通过按照https://github.com/mysqljs/mysql#server-disconnects进行一些错误处理来修复它

    结帐nodejs mysql Error: Connection lost The server closed the connection

    *此问题应标记为重复问题

    【讨论】:

      猜你喜欢
      • 2012-03-17
      • 2019-08-17
      • 2017-06-29
      • 1970-01-01
      • 2019-12-12
      • 2016-03-11
      • 2020-05-04
      • 2022-06-16
      • 1970-01-01
      相关资源
      最近更新 更多