Added proper websocket error handling