Check for null websocket

Fix #744