mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.31k stars 2.53k forks source link

How can I write the reconnection code? #2483

Closed ilkcantnriverdi closed 3 years ago

ilkcantnriverdi commented 3 years ago

Hello, when the connection is lost, I want to reconnect instead of closing the program. When I run this code I get this error. How can I write the reconnection code?

dougwilson commented 3 years ago

Once your connection is broken, you just create a new one to replace it. This module provides the createConnection method to create new connections to your Mysql server.

Depending on your application, it may be easier and more advantageous to use a connection pool instead of trying to write your own connection management code.

ilkcantnriverdi commented 3 years ago

Thank you for your interest. I am already using creatPool. My problem is that when the connection with the server is lost, the program closes and does not wait to connect again.I have to solve this problem.