websocket: fix invalid write