Implemented auto-reconnect for WebSockets.