creating connection handling when the network drops and connection becomes stale