如何避免 node.js 网站程序数据库断开 ?

2014-11-10 10:19:57 +08:00
 typcn
ERR [Sun Nov 09 2014 06:52:16 GMT+0800 (CST)] Error: Connection lost: The server closed the connection.
ERR [Sun Nov 09 2014 06:52:16 GMT+0800 (CST)] Mysql Connect error: connect ECONNREFUSED
ERR [Sun Nov 09 2014 06:52:18 GMT+0800 (CST)] Mysql Connect error: connect ECONNREFUSED
ERR [Sun Nov 09 2014 08:21:41 GMT+0800 (CST)] Error: Connection lost: The server closed the connection.
ERR [Sun Nov 09 2014 08:21:41 GMT+0800 (CST)] Mysql Connect error: connect ECONNREFUSED
ERR [Sun Nov 09 2014 09:55:45 GMT+0800 (CST)] Error: Connection lost: The server closed the connection.
ERR [Sun Nov 09 2014 09:55:45 GMT+0800 (CST)] Mysql Connect error: connect ECONNREFUSED
ERR [Sun Nov 09 2014 09:55:47 GMT+0800 (CST)] Mysql Connect error: connect ECONNREFUSED
ERR [Sun Nov 09 2014 11:32:28 GMT+0800 (CST)] Error: Connection lost: The server closed the connection.
ERR [Sun Nov 09 2014 11:32:28 GMT+0800 (CST)] Mysql Connect error: connect ECONNREFUSED
ERR [Sun Nov 09 2014 11:32:30 GMT+0800 (CST)] Mysql Connect error: connect ECONNREFUSED

昨天刚做好的博客系统 用 Supervisor 运行,一天多 数据库断了4次,被杀了十几次
3149 次点击
所在节点    Node.js
3 条回复
ipconfiger
2014-11-10 10:21:39 +08:00
在连接空置断开前,自己主动断了重连就行了
typcn
2014-11-10 10:41:00 +08:00
@ipconfiger 我想保持长连接,可以通过修改配置文件实现吗?
ipconfiger
2014-11-10 10:46:30 +08:00
MySQL有个连接空闲XX时间就断开的设置,要么去MySQL禁用掉这个设置,要么
就按我说这个办法,其实仍然是长连接的,所谓长连接并不是永远连接的意思。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/145267

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX