Issure #45 fix

Test the connection with ping if needed and reset connection if ping failed, before further processing query.