Recent

Author Topic: Keeping MySQL connected  (Read 209 times)

tetla68

  • Newbie
  • Posts: 1
Keeping MySQL connected
« on: October 09, 2020, 09:27:46 pm »
Newbie here/Hobby programmer.

I am playing with Lazarus specifically I like to connect and keep the connection on to MySQL server at home. At home I am running free community version MySQL Server  v5.7. Now I tried both standard MySQL library that comes with Lazarus v2.0.10 and ZEOS library v7.2.6 and in both instances I run into the same issue, when connected locally I stay connected for long period of time even without any activity no problem there but when I use the same program and connect over the internet after about 3 minutes or so of inactivity I get disconnected and I have no graceful way to close the connection/open tables only way to re-connect is by selecting abort option, crash the program and then re-start.  Now I don't know if these MySQL variables play any role in this but both  "wait_timeout" and "interactive_timeout" are set at 28800 which I figure if it's seconds that should be 8 hours. Are there any parameters I need to pass on to MySQL connection over the Internet to keep it active?

And I don't even know where or how to trap the error message, basically on connection I have a query open in a grid, after a period of inactivity when I try to move to another row I get an error dialog "SQL Error: MySQL server has gone away." and only option I have is to click OK or abort, when I select OK and then try to close the connection the same dialog pops up again I have no way of closing the connection, only option I have is to abort and terminate the program. I am sure there must be a way to trap this error close the bad connection and try to re-connect.

Any tips on what I am doing wrong here and how to "fix" this?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8903
  • FPC developer.
Re: Keeping MySQL connected
« Reply #1 on: October 09, 2020, 11:24:18 pm »
Probably setting some property on the connection, like https://zeoslib.sourceforge.io/viewtopic.php?t=3246

 

TinyPortal © 2005-2018