Welcome! Log In Create A New Profile

Advanced

ERROR 2013 - Lost Connection to MySQL server

Posted by Dan M 
Dan M
ERROR 2013 - Lost Connection to MySQL server
June 16, 2009 10:40PM
The summary:

How do I re-connect to the server when my connection is sleeping?

I created a connection to the server when I created my Analysis using external files.

when I run the program it works but if I do not access the data within 15 second I get the error. According to the ISP they kill sleeping connections after15 seconds but said that the DB should automatically re-connect when the next query is executed.

this makes sense to me but it is not re-connecting. The prorgam is aborted.

PC Soft Free Technical support said ...

This is a MySQL server problem. I suggest you to search for "mysql error 20123" with Google. You will find a lot of information about the error and how to get rid of it.

This is not a WinDev problem.


--------------------------------------------
I do not think this is true????

how do I re-connect to the server after my sleeping connection is killed?



More details :
---------------------------------------------------------------------------------------------------
I am developing a back office application which accesses a MYSQL database which is used for my website.I created tehe connection to the DB when I set up the Analysis.

I am constantly getting the following error :

Request Summary (10 words maximum):
Lost connection to MySQL server during query

Request Details:
Error at line 1 of Click BTN_View process.
HReadSeekFirst function called.
native MySQL access error.
Error Number = 22

Error returned by <xx.xx.xxx.xx> database:
Error Number = <2013>.
Error Message:
Lost connection to MySQL server during query

----------------------------------------------------------------------------------------------

I contacted PC Soft and received the following response ...

This is a MySQL server problem. I suggest you to search for "mysql error 20123" with Google. You will find a lot of information about the error and how to get rid of it.

This is not a WinDev problem.

----------------------------------------------------------------------------------------------
This is the response from my ISP ...

The server will kill off any queries or sleeping connections that last over 15 seconds. The sleeping connections being killed off is not generally an issue because it will just re-connect when needed. Are you having any actual problems with the site?

The sleeping connections that are killed off should just reconnect automatically. You should not have to manually code in the database connection string again. Are you have issues with the back office application currently?

-----------------------------------------------------------------------------------------------

This makes sense because if I am not constantly hitting the server the connection is sleeping and I loose the connection ....

How do I re-connect?
Novica Njagojevic
Re: ERROR 2013 - Lost Connection to MySQL server
June 17, 2009 12:40AM
Make automated procedure,that fires every,for exaple 10 minutes or less,and
searches something in the database.
This should work behind the scene and your connection is preserved.

Thanks for the suggestion but as I wrote, my ISP kills sleeping connections after 15 second.


Every10 minutes would not help and I dont think I should be hitting the server every 10 seconds to maintain a connection.

According to my ISP the connection should reconnect automatically??

How do I get WinDev to automatically re-connect when the ISP is killing my connection after 15 seconds of inactivity?
Well I am not sure if this is how it is supposed to be done but as I hack away this is what I have found works ...

1. use HOpenConnection in the initialization of the project, defining the connection (MyConnection)

2. Then everywhere you query the external database (in my case I am initiating the query in buttons, (example opening a new window to display detailed data or related data), add a line of code like this:

HChangeConnection(*,MyConnection)

(note: the * means all files/tables in the analysis)

This will re-connect to the external database.

Originally if I did not query the external database for more than 15 seconds my connection was lost and the program would crash/abort. After adding this code I have let the machine sit idle for up to 10 minutes and everything works with no disconnect.

Hop this helps someone else using external DB save a few hours ...
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: