WebSocket's send() method is wrong. The write() operation on an asynchronous SocketChannel will only send as many bytes as can be written to the socket's buffer without blocking (which is what makes it asynchronous). So you can't simply assume that you can just call write() once and you're done. There may still be data in the ByteBuffer that needs to be sent. You need to call remaining() on the ByteBuffer to check this.
I'm attaching a rather large patch that implements the asynchronous I/O the right way. So far, it's working for me.
WebSocket's send() method is wrong. The write() operation on an asynchronous SocketChannel will only send as many bytes as can be written to the socket's buffer without blocking (which is what makes it asynchronous). So you can't simply assume that you can just call write() once and you're done. There may still be data in the ByteBuffer that needs to be sent. You need to call remaining() on the ByteBuffer to check this.
I'm attaching a rather large patch that implements the asynchronous I/O the right way. So far, it's working for me.