mySQLCommunityServer: Autoclose Connections

TLDR; will mySQLCommunityServer Connection automatically be closed when the Programm quits?

Since we installed a new firewall, we have had a problem where over a certain period of time, the number of connections to mySQL servers (port 3306) are established but not terminated. Our new firewall does not terminate these connections after a timeout because we need it that way, which was one of the reasons for the new firewall.

Our Xojo programs use the mySQLCommunityServer intensively, but do not close the connections because they are needed again and again. No close was inserted when the programs were closed either, because I assumed that the connections would be closed automatically when the program was closed.

Am I right in assuming that mySQLCommunityServer connections are closed automatically when my programs are quitting or do I have to do this explicitly in the programs?

Is it possible that the connections are closed automatically when I quit the App, but not while debugging, and that is why there are too many open connections left open?

Until someone like @William_Yu f.e. can answer this, i’ve added:

If self.IsConnected Then self.Close

to the Destructor of my mySQLCommunityServer Subclass.

They should be closed automatically if the MySQLCommunityServer instance is properly destructed. The only time this would fail is if somehow we mismanaged the lock/unlock state. If this is what’s happening please file an Issue and we can investigate further.

There should not be any difference between a debug run and running the built app.

3 Likes

Since our firewall can’t determine which program is opening so many connections over a longer period without closing them afterward, I just wanted to make sure that my program isn’t the one causing these numerous connections.

Thank you, @William_Yu . Your response is all I wanted to know. :slight_smile:

Yes. Don’t worry about it. Happens automatically. The OS will close the socket when app ends and the connection is gone.

2 Likes

Thank you @Christian_Schmitz, that also helps a lot. :+1: