You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The undertow websocket implementation close doesn't appear to actually close the connection, it just calls the close handler. Additionally it doesn't check if the websocket session is already closed, which can easily result in infinite recursion (e.g. onClose calling a cleanup function also called by onError, which then calls close).
Unfortunately the infinite recursion is still an issue:
at io.jooby.internal.utow.UtowWebSocket.onError(UtowWebSocket.java:230)
at io.jooby.internal.utow.UtowWebSocket$1.onError(UtowWebSocket.java:255)
at io.jooby.internal.utow.UtowWebSocket$1.onError(UtowWebSocket.java:251)
at io.undertow.websockets.core.WebSockets.sendInternal(WebSockets.java:915)
at io.undertow.websockets.core.WebSockets.sendInternal(WebSockets.java:900)
at io.undertow.websockets.core.WebSockets.sendClose(WebSockets.java:856)
at io.undertow.websockets.core.WebSockets.sendClose(WebSockets.java:831)
at io.jooby.internal.utow.UtowWebSocket.handleClose(UtowWebSocket.java:250)
at io.jooby.internal.utow.UtowWebSocket.close(UtowWebSocket.java:139)
at foo.AbstractWebsocketHandler$PostInit.onError(AbstractWebsocketHandler.kt:93)
at foo.AbstractWebsocketHandler.handle$lambda-4$lambda-2(AbstractWebsocketHandler.kt:35)
Maybe calling IoUtils.safeClose(channel) before calling the error handler in io.jooby.internal.utow.UtowWebSocket#handleClose#WebSocketCallback#onError would fix it? As far as I can see that should immediately set org.xnio.Connection#state so that io.jooby.internal.utow.UtowWebSocket#isOpen will return false.
The actual exception is
java.io.IOException: UT002002: Channel is closed
at io.undertow.websockets.core.WebSocketChannel.send(WebSocketChannel.java:343)
at io.undertow.websockets.core.WebSockets.sendInternal(WebSockets.java:906)
at io.undertow.websockets.core.WebSockets.sendInternal(WebSockets.java:900)
at io.undertow.websockets.core.WebSockets.sendClose(WebSockets.java:856)
at io.undertow.websockets.core.WebSockets.sendClose(WebSockets.java:831)
at io.jooby.internal.utow.UtowWebSocket.handleClose(UtowWebSocket.java:250)
at io.jooby.internal.utow.UtowWebSocket.close(UtowWebSocket.java:139)
Activity
jknack commentedon Apr 26, 2022
Thank you, this bug was across all servers.
U1F984 commentedon Apr 28, 2022
Hi, thanks for the super fast fix.
Unfortunately the infinite recursion is still an issue:
With the AbstractWebsocketHandler having this:
configurer.onError { ws, throwable -> foo.onError(ws, throwable) } // foo: ws.close(WebSocketCloseStatus.SERVER_ERROR)Maybe calling
IoUtils.safeClose(channel)before calling the error handler in io.jooby.internal.utow.UtowWebSocket#handleClose#WebSocketCallback#onError would fix it? As far as I can see that should immediately set org.xnio.Connection#state so that io.jooby.internal.utow.UtowWebSocket#isOpen will return false.The actual exception is