[Sqlrelay-discussion] setConnectTimeout() not working correctly?
Brought to you by:
mused
From: Cal H. <ca...@fb...> - 2013-12-31 20:09:12
|
Hi David, I'm attempting to write a weighted round-robin connection method for an easy failover mechanism on multiple SQL Relay servers. It appears that the C++ sqlrconnection::setConnectTimeout() function isn't behaving like I'd expect. It seems that no matter what values I pass to it, the connection *always* fails. Here's the general idea I'm doing: bool success = false; do { /* select random sql relay server */ tmpconn = new sqlrconnection(hostname, port, NULL, user, pass, 0, 1); tmpconn->debugOn(); tmpconn->setConnectTimeout(10, 5000000); const char *version = tmpconn->serverVersion(); printf("version: '%s'\n", version); if ( version ) success = true; /* Breaking out after a few tries */ } while ( success == false ); Running that, I get something like this: <pre> Connecting to listener... </pre> <pre> Inet socket: 127.0.0.1:9000 </pre> <pre> Setting Error </pre> <pre> Couldn't connect to the listener. </pre> version: '(null)' But when I comment out the setConnectTimeout() call, it works just fine: <pre> Connecting to listener... </pre> <pre> Inet socket: 127.0.0.1:9000 </pre> <pre> Authenticating : ... </pre> <pre> Server Version... </pre> <pre> Checking for error </pre> <pre> No error occurred </pre> <pre> 0.53.1 </pre> version: '0.53.1' I've played around with different values for seconds and microseconds. (I want a timeout of 5 seconds, however that can be accomplished) Thanks for any help! --Cal |