Add lock to websocket object to prevent threading errors