Page 1 of 1

[SOLVED] Set timeout on unresponsive mysql server

Posted: Sat Sep 29, 2007 10:30 pm
by phice
Hey everyone,

I'm trying to look for a configuration file or a flag to call when using mysql_connect with a remote server, that might be inactive/offline, in order to decrease the wait/load time until mysql_connect spits back saying the server is unresponsive. Currently it takes about 10-15 seconds until the mysql error "Access denied for user 'ODBC'@'localhost' (using password: NO)" comes back.

FYI, this is not a problem in my coding. I have a computer on the network running mysql independently and currently have it turned off in order to test the page response of mysql turned off.

Anyone have any idea? I can't seem to find any relative information on php.net/mysql_connect

Posted: Sat Sep 29, 2007 10:52 pm
by feyd
Maybe use cURL/fsockopen to attempt a connection first that has a short timeout ... ?

Posted: Sat Sep 29, 2007 11:10 pm
by phice
That would seem to be a bit bothersome for a highly active website, establishing two connections per page load. Surely there has to be a timeout variable in the configuration somewhere for php's mysql extension.

Posted: Sat Sep 29, 2007 11:11 pm
by phice
Wow, I feel stupid -- "mysql.connect_timeout" in php.ini for PHP >= 4.3.0

case closed :oops: