avoid locking when message queue is empty in websocket