Tomasz Kryński Tomasz Kryński - 11 months ago 68
Android Question

Netty websocket close gracefully

I need to make my websocket to close gracefully. Firstly send all messages that are waiting in buffer then close.


seems not right, because I dont have any completion handler for flush method to do close after it is done.

Is there any way to do this.
Netty used: 4.1.0.Beta3

Answer Source

The trick you can use is to writeAndFlush an empty buffer, then attach a listener to that call. Unpooled.EMPTY_BUFFER can make this pretty easy.