Thanks Stuart,
Did not see this method in 1.0.x since it was added at a later release - tried with latest version and it works well.
However, I figured out that connection termination works well iif receive setter is set:
WebSocketChannel channel = ...;
channel.getReceiveSetter().set(new AbstractReceiveListener() {});
channel.addCloseTask(new ChannelListener<WebSocketChannel>() {
@Override
public void handleEvent(WebSocketChannel channel) {
...
}
});
If receive setter is not set, then close task will not be called. In my case there was no intent to receive messages from the client and just push them from the server. Receive setter was not set => connection was not closed.
It seems obligatory to set receive setter all the time to make the thing work. Is it intended? While it is not a big deal really, I would imagine that Undertow should handle connection termination without explicit receive setter call made by the API client.