After switching from jooby-undertow to jooby-netty, issue #3111 can be reproduced again with the lastest version. Using undertow with the latest version works correctly ("Connected" followed by "Disconnected").
If the socket is actively used by writing to it, there is an error:
java.lang.IllegalStateException: Attempt to send a message on closed web socket
at io.jooby.internal.netty.NettyWebSocket.sendMessage(NettyWebSocket.java:178)
at io.jooby.internal.netty.NettyWebSocket.send(NettyWebSocket.java:111)
at io.jooby.WebSocket.send(WebSocket.java:205)
at App$1$1$1.invoke(ServerMain.kt:16)
at App$1$1$1.invoke(ServerMain.kt:13)
at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
and the socket is marked as closed (isOpen returns true since the netty channel is dead), but the handleClose and so onClose callback is not invoked.
If I insert:
this.netty.ctx.channel().closeFuture().addListener(future -> handleClose(WebSocketCloseStatus.GOING_AWAY)); // or some other close status
into the constructor, the onClose is invoked successfully.
After switching from jooby-undertow to jooby-netty, issue #3111 can be reproduced again with the lastest version. Using undertow with the latest version works correctly ("Connected" followed by "Disconnected").
If the socket is actively used by writing to it, there is an error:
and the socket is marked as closed (isOpen returns true since the netty channel is dead), but the handleClose and so onClose callback is not invoked.
If I insert:
into the constructor, the onClose is invoked successfully.