-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Jakarta websocket @OnMessage with Reader parameter stops working when there is an unhandled exception #11275
Comments
Smells like a bug in our impl. BTW, Do you have a |
Note: Jetty 10 / 11 has reached End of Community Support Should this bug exist in Jetty 12, it will be fixed there. |
@natan-abolafya are you using websocket permessage-deflate extension? |
that is not something I've enabled intentionally. This is what I use to integrate jetty websocket to my dropwizard application which maybe enables it under the hood?
|
I can't seem to reproduce this. Whenever an exception is thrown we immediately catch and fail the callback, after failing the callback the connection will be closed then Could you provide some debug logs when you experience this issue. Or perhaps a small example project which can reproduce it. |
I was afraid of this :) but to be fair, it would have been caught earlier if that was easy to reproduce. So, I've done some testing on my application where I made other changes and could not reproduce. It is behaving exactly as you said. Then I remembered that I had changed the
I think I had also tried |
Note that using Reader or InputStream in your Those two signatures, while valid, should be used sparingly as they incur quite a large hit on performance. Devs often want to use Reader / InputStream because they want to reduce memory vs a whole message delivery. Another option you have is to use the "ByteBuffer / boolean" pair (for BINARY) or "String / boolean" pair (for TEXT). |
Hey. Thanks for the insight. Quite interesting. When we tested at the time, if we used
Anyway, the issue is still valid I suppose. It caused quite a lot of headache as it was quite hard to figure out (we've pursued quite a few red herrings :)). Would be good to spare other people hitting this IMHO. |
You can still do that by accepting the raw websocket message and sending that out (or queuing) to a thread that your app controls to handle the messages. If that handling queue is getting too big, just don't exit the |
Interesting, seems like this is a bug. I can see a case where this could happen specifically when using the As a workaround I would just catch the exception and do a |
yep, that's what I've ended up doing in the end and at the same time changing it to String without knowing :). Thanks for all the help!. |
…ispatchedMessageSink Signed-off-by: Lachlan Roberts <[email protected]>
Signed-off-by: Lachlan Roberts <[email protected]>
…DispatchedMessageSink (#11343) * Now properly handling errors * Added test for partial read Signed-off-by: Lachlan Roberts <[email protected]>
Jetty version(s)
11.0.19
Java version/vendor
openjdk 21.0.1
OS type/version
Ubuntu 22.04
Description
I've been debugging and trying to figure out a bug where our application stops getting websocket messages while the websocket is clearly alive, responding to pings and it is sending messages initiated from other places in the code.
Turns out the database goes down at some point which leads to a RuntimeException in the code where the incoming messages are handled (@OnMessage). The exception seems to be silently ignored and the whole websocket is basically stuck in one direction. UPDATE: seems to only happen when
Reader
orInputStream
parameters are used.I suppose it is connected to this:
Except the lock (assuming there is a lock) is never released on that websocket connection when an exception occurs. And I think it should be released.
How to reproduce?
The text was updated successfully, but these errors were encountered: