ping/pong and auto reconnect refactoring