Lost connection in qry->exec()
-
Hi,
I am using the MySQL database to connect remotely from my application, I check for connection to server before every query exec(), but If I break the connection after the check (i.e on the way executing qry->exec()) my application hangs and not responding any further.
Here the disconnection is done by me by removing the internet cable.How to detect the connection lost during the query execution, if lost how to recover (both the options MYSQL_OPT_RECONNECT=TRUE or MYSQL_OPT_CONNECT_TIMEOUT=10 are not helping) or timeout the connection.
Thanks,
Kanni -
Hi,
I am using the MySQL database to connect remotely from my application, I check for connection to server before every query exec(), but If I break the connection after the check (i.e on the way executing qry->exec()) my application hangs and not responding any further.
Here the disconnection is done by me by removing the internet cable.How to detect the connection lost during the query execution, if lost how to recover (both the options MYSQL_OPT_RECONNECT=TRUE or MYSQL_OPT_CONNECT_TIMEOUT=10 are not helping) or timeout the connection.
Thanks,
Kanni@Kanni1303
This was discussed at length a while back on this forum (sorry, I don't have the link), and the outcome I believe was you are just not going to be able to detect this or make it timeout. Sorry, if someone else knows better you will have more luck. -
I am talking to a print server at port 9100. I cannot tell when it loses connection. So I connect to the webserver the printer has once every 2 seconds and transfer the data (500 bytes). If this transfer fails I disconnect from port 9100 and start trying a reconnect.
Can you make a dummy second connection (doesn't have to be a database connection, just a port connection) to test if it passes or fails? Then use this result to determine if the original connection is any good.
-
@fcarney I always detect the internet is good (Ping the server, this verifies route to server is available) before establishing connection to server but the problem is if I disconnect from internet during exec the query, my application hangs and no control. I want to timeout and abort the connection established by qry->exec() and take back application control. what is happening, why application hangs is there any retry count? timeout? error handling?
-
@Kanni1303
This was discussed at length a while back on this forum (sorry, I don't have the link), and the outcome I believe was you are just not going to be able to detect this or make it timeout. Sorry, if someone else knows better you will have more luck. -
@Kanni1303
I know you do. Which is why I explicitly wrote that this has been asked before and the gist is you cannot have one. What else do you want me to say?