Getting started with Membership etc

Postby mobyscore » Mon 30 Jul 2007 14:46

If I am trying to use an old connection (which I am not) then I can see that an eight hour time out is a more than reasonable time for it to have been kept alive before being destroyed.

But as you can see from my code, I am setting up a new connection each time the web page is requested, so it cannot be anywhere near 8 hours old. The "lost connection" message is returned immediately the page is requested (< 1second).

It's almost as if when I set up the new connection using the ConnectionString method it thinks there is a connection that can be used, but in fact there is not (because it has been destroyed). However if I set up the connection using object properties instead, it correctly creates a new connection and there is no problem. Surely if "wait_timeout" was the problem it would affect the "property setting" method in the same way as the ConnectionString method?

The "lost connection" only happens once, on the first MySQL access in the day.

Having read this do you still think it is worth me changing "wait_timeout"?
mobyscore
 
Posts: 17
Joined: Mon 28 May 2007 11:05

Postby Alexey » Mon 30 Jul 2007 15:35

Try to set Pooling=false in the connection string.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby mobyscore » Tue 31 Jul 2007 07:43

The error has gone away, but the response to each request is now noticeably longer.
mobyscore
 
Posts: 17
Joined: Mon 28 May 2007 11:05

Postby Alexey » Tue 31 Jul 2007 11:54

I see. Then do not disable pool. You can catch the exception in your code instead. Or use MySqlConnection.Ping() method to check whether connection is still alive.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby mobyscore » Wed 01 Aug 2007 08:20

You are correct - Ping returns "false" when the error occurs. So I can detect it.

Having detected the error, I want to make a connection that does not fail so I've:

(1) Closed the connection which has the error
(2) Set that connection to Nothing to destroy it
(3) Called MySqlConnection.ClearAllPools()
(4) Created a new connection and openned that

To avoid fiddling with the MySQL setup I need to wait 8 hours before testing this.

From your documentation I am a little concerned that step (3) will not work, as this call is asynchronous and take 30 seconds. Is there a better way of guaranteeing a good connection?

I must say I'm a little concerned that I'm writing code that is trying to overcome a problem that appears to lay in either MySQLDirect or MySQL. Am I correct in thinking code beneath mine tries to use an invalid internal database connection as soon as I create a new instance of a MySqlConnection?
mobyscore
 
Posts: 17
Joined: Mon 28 May 2007 11:05

Postby Serious » Wed 01 Aug 2007 09:30

If MySqlConnection.Ping returns false, the connection is automatically removed from the pool, so you don't have to call MySqlConnection.ClearAllPools(). Actually, setting connection instance to Nothing does nothing (in terms of the underlying physical connection) if you previously closed it.

So I propose the following algorithm: if Ping() returned false, you should close the connection, create a new one and open it.
Serious
 

Postby mobyscore » Thu 02 Aug 2007 08:46

Thank you (and for the prompt responses). The check and recovery appear to work fine.
mobyscore
 
Posts: 17
Joined: Mon 28 May 2007 11:05

Postby Alexey » Thu 02 Aug 2007 09:12

You are always welcome.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Same Problem

Postby unreallity » Mon 13 Aug 2007 18:46

Hi there... what was the wrong setting in web.config?

I have the same problem, but with PgSql (the problem with unknown Keyword :HOST)

this is the connection string
Code: Select all



when changing it to:
Code: Select all
add name="LocalPgSqlServer" connectionString="User Id=test;Password=test;Server=localhost;Database=test" providerName="CoreLab.PostgreSql"/>


(deleted Schema and renamed Host to server),

i get Connection refused and it does not work anyway

Thank you for comments
unreallity
 
Posts: 3
Joined: Mon 13 Aug 2007 18:31

?

Postby unreallity » Tue 14 Aug 2007 17:01

Someone alive? :-)
unreallity
 
Posts: 3
Joined: Mon 13 Aug 2007 18:31

Postby Alexey » Wed 15 Aug 2007 07:14

Please create new thread in appropriate forum and move your inquiry there.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Previous

Return to dotConnect for MySQL