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

Cannot send partial message with JettyWebSocketSession #34088

Open
OPeyrusse opened this issue Dec 13, 2024 · 3 comments
Open

Cannot send partial message with JettyWebSocketSession #34088

OPeyrusse opened this issue Dec 13, 2024 · 3 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@OPeyrusse
Copy link

As we can see in the code snippet below, it is not possible to send TextMessage where isLast is set to false.

protected void sendTextMessage(TextMessage message) throws IOException {
useSession((session, callback) -> session.sendText(message.getPayload(), callback));
}

public TextMessage(CharSequence payload, boolean isLast) {
super(payload.toString(), isLast);
this.bytes = null;
}

However, the API exists in Jetty, in the form of Session#sendPartialText(String, boolean, Callable). Is there any reason for not using it?

https://github.com/jetty/jetty.project/blob/jetty-12.0.x/jetty-core/jetty-websocket/jetty-websocket-jetty-api/src/main/java/org/eclipse/jetty/websocket/api/Session.java#L99-L110

From basic testing, it seems that calling it is still not complying, but I may have made boggus changes and broken the code.

Thank you for any reply

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 13, 2024
@snicoll snicoll added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Dec 16, 2024
@sdeleuze
Copy link
Contributor

I am not sure about the reason, but FWIW tests are green when doing this change.
Notice the same apply to binary messages with Session#sendPartialBinary.

@OPeyrusse I am not sure to understand "From basic testing, it seems that calling it is still not complying", could you please elaborate?
@rstoyanchev Do you know if there is a good reason or if you think there is something to refine here?

@sdeleuze sdeleuze added the status: waiting-for-feedback We need additional information before we can continue label Dec 23, 2024
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Dec 30, 2024
@OPeyrusse OPeyrusse changed the title Cannot send partial message with Cannot send partial message with JettyWebSocketSession Dec 31, 2024
@OPeyrusse
Copy link
Author

@sdeleuze Yes. I haven't looked at #sendPartialBinary as I was not interested in this method, but it likely does the samen

"From basic testing, it seems that calling it is still not complying", could you please elaborate?

With a spring test application backed by Jetty, we were having this problem where we could not send partial messages.
After finding the awkward method ignoring the flag isPartial, we attempted to hot-fix the class, manually calling session.sendPartialText(message.getPayload(), message.isLast(), callback).
We observed that jetty was still somewhere ignoring this flag, as we were receiving in the client two messages marked as final.
Hence my question asking if the choice of Jetty message was intended.

In our test setup, we are trying to send a 40MB message - to force the chunking and usage of partial messages.
Our code is created a first message of 30MB, marked as last = false and a second one of 10MB marked by our code as last = true.
Inside jetty, as the message is too big for a single send, we observe that it is chunked into smaller pieces. The first message is chunked in multiple parts, the last part being marked as last, despite our original message saying otherwise.

That is also why my question is suggesting that this may be done on purpose, knowing that jetty implementation still does not support partial message, for some reason.

I completely understand that the above is mostly words. As you seem as puzzled as I am and you seem to think that it is a bug more than a feature, I will try to build a reproduction example in the coming day (after the new year festivities 🎉 )

Cheers

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

4 participants