Page 1 of 1

Lost connection to MySQL server during query

Posted: Thu 26 Jun 2008 19:54
by jammerjam
I've got 2 seperate VB.NET applications that are getting disconnected.

Code: Select all

App 1:
MyDirect.Net 4.3
MySQL 4.0.22 on server #1

Creates connection, executes SELECTs, DELETEs and INSERTS, closes connection.

Code: Select all

App 2:
MyDirect.Net 4.7
MySQL 4.0.22 AND MySQL 5.0 on server #2

Creates connection, pulls 1000 records into a data reader and loops through, closes connection.
In both instances the connection will break at ~30 seconds reliably. App 2 was tested against 2 different versions of MySQL...and broke both times.

Code: Select all

Connection String attempts:
SERVER=server;PORT=3306;DATABASE=Test;USER=root;PASSWORD=SECRET;Pooling=true;Max Pool Size=3;Connection Timeout=10;
SERVER=server;PORT=3306;DATABASE=Test;USER=root;PASSWORD=SECRET;
SERVER=server;PORT=3306;DATABASE=Test;USER=root;PASSWORD=SECRET;Pooling=false;Max Pool Size=3;Connection Timeout=10;
SERVER=server;PORT=3306;DATABASE=Test;USER=root;PASSWORD=SECRET;Pooling=true;Max Pool Size=3;Connection Timeout=100;
As seen above I tried numerous connection strings to get this to work. Unfortunately I cannot copy & paste actual code, and the apps themselves are fairly complex.

I've even attempted to Ping() the connection before App #2 reads each record but that didn't help. I also am attempting to Ping() the connection before Open() it.

Suggestions?

Posted: Thu 26 Jun 2008 22:34
by pleb
do you get an error message? if so what is it?

Check to make sure you're closing the connections properly.

Test the network by running a few queries in a product like MyDeveloper or MySQL Query Browser and see if they also error. If they do it's probably a problem to do with the network, such as firewall, routing rules, etc...

Posted: Fri 27 Jun 2008 11:13
by Alexey.mdr
Hello,

Firstly, as pleb has already mentioned above, the exception message is quite important.
Secondly, when you use pooling try increasing the max pool size property, or just omit it (the default value is 100)

Code: Select all

Pooling=true;Max Pool Size=3;
Does it make sense?

P.S.: there is no need of max pool size property set when you do not use pooling.

Code: Select all

Pooling=false;Max Pool Size=3;
Regards,
Alexey.

Posted: Fri 27 Jun 2008 12:41
by jammerjam
The error is: Lost connection to MySQL server during query

All connections are closed but when I run the app it's not even getting that far. Here's what it does:

Code: Select all

1.  Open connection
2.  Run a select command and return data reader
3.  Iterate through data reader
4.  After 30 seconds - get error:  Lost connection to MySQL server during query
5.  In finally block close connection.
6.  Done.
I tried setting the max pool size back to 100 and that didn't affect anything. The commands work fine in MySQL Query Browser.

Posted: Fri 27 Jun 2008 13:12
by pleb
Hi jammerjam,

I have a few ideas...

Could you post your connection string (minus username, password, ip address) ;)

Is this your server? Maybe a hosting account of some sort? Possibly going through a VPN?

Is it code execution getting to the iterate through results stage?

Does the server have some type of script that runs to kill long running queries? (MySQL can't do this by default, but cron + bored sys admin can) Instead of logging long running queries some admins like to kill them.

Regards Pleb

Posted: Tue 01 Jul 2008 08:52
by anton.connect
jammerjam, have you solved your problem? Please let me know.

Posted: Fri 19 Sep 2008 13:55
I had the same problem. Originally I defined the datacontext as a static member variable and run it on IIS. I just had to make a non-static member.
________
VIDEO REVIEW

Posted: Wed 24 Sep 2008 10:00
by Shalex
Please specify more clearly the problem. What is the text of the error? What are the steps we should take to reproduce it? Could you please send me (alexsh at devart.com) a test project and the script that creates the tables and fills them with data?