Tomasz Kryński Tomasz Kryński - 1 year ago 106
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download