문제

I'm using Nodejs to write a socket server for my app (using Corona SDK), and so far so good, and I'm using node-mysql (page for node-mysql), and that works too, but... if nothing happens and nothing uses the connection to the db, after 2 minutes (which is the default timeout) the connection closes, while I need it to remain always open as long as the scrip process is still running, can I simply set the timeout attribute of the connection to 0, and that will keep it always open, or do I need to set it for a really long time, like 24 hours (in millisecond) in order to keep it up at all times (I'm putting 24 hours since our server restarts once a day anyway).

Thanks!

도움이 되었습니까?

해결책

Well, it would seem the problem was the mysql server wait_timout, which was set to 300 seconds (5 minutes), and it was what disconnected my script. seeing as I don't really want to change that variable since not only my script uses that DB, for the time being I'm simply executing a light query with a setInterval every 4 minutes, hoping this will keep my connection alive.

다른 팁

If you want to keep your MySQL server always running, you have to set the connectTimeout option to 0. See the the commit "Default connectTimeout to 2 minutes". 0 was the default option before.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top