How to recover from a network failure wrt Cloud RDS in a closed loop system

currently implemented algorithm

1)initialize handle

  1. while(true)
    {
    if Ping successful then continue
    else disconnect then reconnect // At this point of reconnection, the code gets stuck
    }

It gets connected the first time, but later due to various factors including detachment of LAN cable, the reconnection function ( Connect()) gets stuck

Can you let us know the correct sequence of Open(), Close(), Connect(), Quit(), & Ping() functions in the Cloud RDS API

Please refer the sample code from here about how the reconnect is implemented.
Please let us know, is this solves your problem.

Having implemented the reconnection function as a thread,

if the time interval between LAN detachment and a reconnection attempt is a few seconds, it works, else if it is greater than 6 min MySqlConnect() it still gets stuck