Skip to content

Keep getting timeout after a few minutes of idle on google cloud sql #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
badoet opened this issue Jul 22, 2014 · 8 comments
Closed

Keep getting timeout after a few minutes of idle on google cloud sql #878

badoet opened this issue Jul 22, 2014 · 8 comments
Labels

Comments

@badoet
Copy link

badoet commented Jul 22, 2014

is there any compatiblity issue of this driver with the google cloud sql ?
https://developers.google.com/cloud-sql/
it seems that we keep getting time out after a few minutes of idle time.
do anyone in the community face the same issue?

thx

@sidorares
Copy link
Member

Are you able to connect using command line client?

@badoet
Copy link
Author

badoet commented Jul 22, 2014

yeap. it does.
i kinda figured out the issue, the google cloud sql will 'sleep' after 15min of inactivity - for the pay per use and 12 hours of inactivity - for the package billing.
this morning we experience high cpu usage in the server, which might cause more error than what it should with the db connection.
so will monitor again tomorrow if its still giving us the timeout error.
there r other people who face the same issue too :
http://stackoverflow.com/questions/21457437/first-connect-from-prestashop-to-google-cloud-sql-always-fails

@dougwilson
Copy link
Member

it seems that we keep getting time out after a few minutes of idle time.

Can you post the timeout error you're getting?

@dougwilson
Copy link
Member

@badoet I'm closing this issue for now. Please post the timeout error you're getting and I can always re-open the issue.

@lokeshwebmobi
Copy link

Hi dougwilson

I'm getting the following error when i tried to connect after some 15minutes

{"code":"ETIMEDOUT","errno":"ETIMEDOUT","syscall":"read","fatal":true}

@dougwilson
Copy link
Member

Hi @lokeshwebmobi , can you post the stack trace for that error as well? The error itself is saying "Node.js tried to read from a TCP socket that was previously established, but timed out attempting to do so".

@tzmartin
Copy link

tzmartin commented Oct 6, 2015

Just following up for posterity..

Referring to Cloud SQL docs: https://cloud.google.com/sql/docs/compute-engine-access

To keep long-lived unused connections alive, you can set the TCP keepalive. The following commands set the TCP keepalive value to one minute and make the configuration permanent across instance reboots.

# Display the current tcp_keepalive_time value.
$ cat /proc/sys/net/ipv4/tcp_keepalive_time

# Set tcp_keepalive_time to 60 seconds and make it permanent across reboots.
$ echo 'net.ipv4.tcp_keepalive_time = 60' | sudo tee -a /etc/sysctl.conf

# Apply the change.
$ sudo /sbin/sysctl --load=/etc/sysctl.conf

# Display the tcp_keepalive_time value to verify the change was applied.
$ cat /proc/sys/net/ipv4/tcp_keepalive_time

@q42jaap
Copy link

q42jaap commented Jan 25, 2016

@tzmartin setting the keepalive values is not enough, node-mysql should enable keepalive on the socket it uses:
https://nodejs.org/api/net.html#net_socket_setkeepalive_enable_initialdelay

You can see whether the keepalive is active with netstat -o, it will tell you in the last column called Timer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

6 participants