Railway connection closing

Hi! I have this problem regarding railway's deployment. So far, deploying my application is fine, however after a day or at least in a few dozen hours, i get this error:
{
"message": "Can't add new command when connection is in closed state"
}
{
"message": "Can't add new command when connection is in closed state"
}
Anyone how this is caused? and how to prevent this from happening? Thank you.
17 Replies
Percy
Percy7mo ago
Project ID: N/A
TheFriendinYou
TheFriendinYou7mo ago
N/A
Brody
Brody7mo ago
going to need more info, what kind of app is this
TheFriendinYou
TheFriendinYou7mo ago
an app that is connected to azure mysql from a node.js backend. I usually have to redeploy to make it work again. i wonder if azure stops connections over a period of time
Brody
Brody7mo ago
what client library are you using
TheFriendinYou
TheFriendinYou7mo ago
axios
Brody
Brody7mo ago
thats an http request library, we are talking about mysql
TheFriendinYou
TheFriendinYou7mo ago
oh mb, mysql2 npm package?
Brody
Brody7mo ago
are you releasing the connection after your query?
TheFriendinYou
TheFriendinYou7mo ago
no i am not maybe i should use createPool instead?
Brody
Brody7mo ago
are you currently using any kind of pool
TheFriendinYou
TheFriendinYou7mo ago
no i noticed in my code im using one instance of db.connect(), so maybe that causing issues?
Brody
Brody7mo ago
then you should be closing the connections after you make the queries you are currently trying to re-used a closed connection for transparency, this isnt an issue with railway or azure, this is a code issue
TheFriendinYou
TheFriendinYou7mo ago
sorry
Brody
Brody7mo ago
sorry? you havent done anything wrong?
TheFriendinYou
TheFriendinYou7mo ago
its just that most of the other coding platform places are very inactive so im still looking for more places for help
Brody
Brody7mo ago
no worries at all, while coding help is a bit out of scope for these threads, im just trying to push you in the right direction