Fix for concurrent socket access in WebSocket