-
Notifications
You must be signed in to change notification settings - Fork 20
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
MySQLClientException: Can not connect: status is not fresh #45
Comments
Hi booper. You can use connected property to check connection status. Seems like connection is closed and you are trying to use the same connection object to initiate new connection. |
hey, It happens every time when the application with an established connection doesn't communicate with the MySQL server ( version 8 ) for a long time, in my case it is about 3 - 4 hours. |
Can you recreate fresh connection instance? |
You can wrap it in some function which creates connection for you, and then reuse it. |
I am not sure about what to do if connection is closed due to some timeout or other database specific things |
Maybe we need to implement some kind of ping to keep connection alive |
Sure, already handled it, and when catching such an exception I just recreate the connection instance.
Good idea, I am exploring MySQL docs to understand what is the reason MySQL closes the connection with the client on a long time idle. check this out: |
So, based on what I learned: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout MySQL has its [wait_timeout] variable default value set to 28800 seconds (8 hours). So, not a big deal, what I have to do is just check the state of the connection before executing every query and in case of connection is down recreate it. |
Mysql docs is not super informative) |
I am trying to keep the library as slim as possible, meaning that if something can be implemented by user easily it should not be part of this library. I think someone can implement ping by periodically executing some dummy quey like SELECT 1 or similar |
I just need to add this into README. Thank you for investigating this issue |
Thank you for a great job on this lib. Eventually, you are right, keep the lib as slim as possible - the connection handle is the developer's responsibility, not the lib itself :) |
hello, you did a great job on this lib, thank you
From time to time I got this exception:
may you please suggest a good way to manage the connection?
and is there any getter method to check _state of the connection ?
The text was updated successfully, but these errors were encountered: