[SOLVED] Set timeout on unresponsive mysql server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

[SOLVED] Set timeout on unresponsive mysql server

Post 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
Last edited by phice on Sat Sep 29, 2007 11:12 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Maybe use cURL/fsockopen to attempt a connection first that has a short timeout ... ?
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post 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.
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Wow, I feel stupid -- "mysql.connect_timeout" in php.ini for PHP >= 4.3.0

case closed :oops:
Post Reply