adding ping loop to keep the client alive