properly catch exceptions from websocket connection