PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
WINDEV 2024
→
MySQL Server Has Gone Away
MySQL Server Has Gone Away
Started by André Labuschagné, Apr., 15 2018 1:05 PM - 3 replies
Connect yourself…
André Labuschagné
#1
Posted on April, 15 2018 - 1:05 PM
Hi All
I eventually found out why the timer procedure is bombing out. After not writing to MyTable for a length of time, in other words, it is idle on the MySQL side so I suspect the channel is being closed, I get the error below:
//native MySQL access error.
//Unable to open or read <MyTable> file.
//Error Number = 22
//The following error was returned by the <123.123.123.123> database:
//Error number = <2006>.
//Error message:
//MySQL server has gone away - Failed To Reset MyTable
This happens on an HReset(MyTable)
I am confused as HOpenConnection returns true. I am going to try and open the connection in this procedure if any writing is to be done or ignore it. And close it when leaving the procedure if it was opened.
Any other ideas?
Cheers
André
Report
0
0
André Labuschagné
#2
Posted on April, 15 2018 - 4:09 PM
Hi All
Update so far.
It appears that the target Db was disconnecting and WX was not connecting again when the next bunch of writes came around. HOpenConnection on its own did not help at all. What has seemed to have helped is the following:
1. Do NOT handle opening connections and assigning tables to the connection on launching the app.
2. Only open the connection and assign the table to the connection when the procedure is called.
3. Explicitly close the connection when exiting the procedure.
This seems to have worked. Not sure what is going on in the black box at this stage but this seems top be working. I am guessing that not closing the connection was the problem all along.
NOTE: The db we are connecting to is not ours - we have no control over the settings there other than the credentials to connect, read and write.
Cheers
André
Report
0
0
Stefano Giavardi
#3
Posted on April, 15 2018 - 11:07 PM
We experienced the same issue.
Our solution is 1 hopenconnection when starting the application and no hcloseconnection.
We keep 1 connection alive for each app user even if the program stay opened for days.
The trick is launching a "keep alive" to mysql every 10 minutes. For us the "keep alive" is nothing more than a simple query "SELECT NOW()" called by hexecutesqlquery.
It works always, no more lost connection issues.
We use several external compoenents called from the main exe and all share the same db context. Even if i change app module (= open another component) and even if the app uses 10 mysql databases jumping from one to another every second... the mysql connection ID is always the same until the user closes the program.
The second connection per user is only the one we need to open on local HF db to continue working in case central mysql is not available for some reason.
Report
0
0
André Labuschagné
#4
Posted on April, 24 2018 - 6:50 AM
Hi Stefano
Nice solution. Thanks.
Cheers
André
Report
0
0
→ Go back to WINDEV 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text