Page 1 of 1

Lost connection to MySQL server during query - 2

Posted: Fri 04 Apr 2008 18:11
by ahandgraaf
Using VS2008, C#, ASP.Net 2 with AspNetMySqlMembershipProvider / AspNetMySqlRoleProvider / AspNetMySqlProfileProvider / CoreLab.Data 4.50.21 and CoreLab.MySql(.Web) 4.50.25.

The web.config is copy/paste from the examples.

Every 20-25 pageviews I get a
"Lost connection to MySQL server during query" - Server Error

Where the source points to the row with:
MembershipUser user = Membership.GetUser();

I have to use a shared MySQL 5 server and have no influence whatsoever on the configuration (My ISP says it works for thousends of sites without problems, so the problem is on your site).

In my testserver/environment it works without problem I can do hunderds requests a minute without any problem.

Is there something I can configure on 'my' site so the providers start working as they should or can I better use MsSQL Express for the provider part and for the other databasestuff MySQL. I can program around lost connections in my normal pages, but don't know if I or how I can do that for the provider part.

Any help/suggestions are welcome!

Posted: Mon 07 Apr 2008 09:40
by Alexey.mdr
Could you provide a block of code where the exception is thrown?
We need to determine which size drops a connection.
Usually, it's the problem of either MySqlConnection.Timeout or MySqlCommand.Timeout property on the client side.
Try increasing their values.

The code

Posted: Tue 08 Apr 2008 10:52
by ahandgraaf
MembershipUser user = Membership.GetUser();

I don't know exactly where I can manage the settings used by the providers.

In the web.config the following connectionstring is used for the providers:


On my pages I have many queries against the database using the same connectionstring and the connections are never lost, only sometimes when the membership or role provider uses the connection to the database.

BTW: in my testenviroment I'm never able to get those connection Lost errors, but I guess that MySQL-server is configured better then my ISP's or less busy.

Posted: Tue 08 Apr 2008 13:29
by Alexey.mdr
Check that you have explicitly called all MyDataReader.Close();
Do you use multithreading?
Do you connect in Direct mode?
Probably (and it's likely the source of the problem),
the same connection is used by several controls at the same time.
Try using different connections for data loading and memberships/roles.