Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSocket onClose not called for Netty #3452

Closed
U1F984 opened this issue Jun 19, 2024 · 1 comment
Closed

WebSocket onClose not called for Netty #3452

U1F984 opened this issue Jun 19, 2024 · 1 comment

Comments

@U1F984
Copy link
Contributor

U1F984 commented Jun 19, 2024

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.

@jknack
Copy link
Member

jknack commented Jun 20, 2024

@U1F984 would you like to send a PR?

@jknack jknack added this to the 3.1.4 milestone Jun 20, 2024
jknack added a commit that referenced this issue Jun 20, 2024
- WebSocket onClose not called for Netty fix #3452
- Memory leak in jooby-netty fix #3453
@jknack jknack closed this as completed in 7ee4291 Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants