enters a reconnect loop if the socket is closed