-
Notifications
You must be signed in to change notification settings - Fork 148
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
Tomcat TEXT_FULL_WRITING state exception while multiple messages sent from server to client #632
Comments
@ivy-lli Sorry that no one has an answer on this. The core developers of LSP4J don't use websockets much and the websockets bundles have been provided primarily as a convenience for consumers to have that shared code here. If you have a suggested PR I can try to review it. I am tagging some of the known websocket LSP4J users in case they have more insight - they may not have seen your original issue. |
I never seen the reported of error. But I used Websocket mostly in Proof of Concept so far. @ivy-lli Your analysis seems to be consistent and good. |
The approach with a queue sounds good. But strange that the websocket implementation doesn't take care of it by itself. |
@spoenemann I've found another bug request in the tomcat bugzilla archive about this topic: https://bz.apache.org/bugzilla/show_bug.cgi?id=56026 It seems that they strictly followed the spec and the spec don't seems to clearly define if the server or the application should handle this. |
Hi
We use GLSP to display a diagram. GLSP itself uses LSP (LSP4J) as communication layer between server and client.
As our application already has a Tomcat web server we wanted to reuse (same port etc.) this one instead of provide something new like Jetty.
But now we run into many exceptions in our log, that a message couldn't be sent to the client:
After some code investigations and research, this sometime happens when multiple messages are sent to the client at the same "time" (or better quickly after each other). It seems that LSP4J sends here messages without waiting if the last message sending is completed: WebSocketMessageConsumer#sendMessage
The
sendText
method would return aFuture<Void>
to check if the message is sent completely.Tomcat will directly try to send those messages to the client without waiting, it only checks the state of the connection. And because of this the exception above appears:
I've also done some quick researches in Jetty and it seems that there is a queue implemented which handles this "multiple" messages internally (but I'm not sure if I'm right): https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FrameFlusher.java#L78
I'm also not sure what is defined by the WebSocket protocol or the Java API if this should be handled by the server or the protocol (https://tomcat.apache.org/tomcat-9.0-doc/web-socket-howto.html). But if I understood it correctly form an older Tomcat issue, sending multiple messages without waiting is not supported: https://bz.apache.org/bugzilla/show_bug.cgi?id=63931#c1
And I think there is also no way to detect it outside of LSP4J e.g. in the GLSPClient#process, as there is no return value or exception (as LSP4J catches the exception and simply log it: RemoteEndpoint#notify.
So in the end I think the WebSocketMessageConsumer#sendMessage should hold a queue of messages and only send a new one if the previous is sent completely.
Or did I understand something wrong? Thank for you help 🙂
Currently in charge:
The text was updated successfully, but these errors were encountered: