Add check for null WebSocket