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

TEXT_PARTIAL_WRITING exception #793

Closed
fschmuck opened this issue Sep 13, 2023 · 6 comments
Closed

TEXT_PARTIAL_WRITING exception #793

fschmuck opened this issue Sep 13, 2023 · 6 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@fschmuck
Copy link

fschmuck commented Sep 13, 2023

I am using spring graphql with webflux and sometimes receive this exception.
I don't know whats the cause behind it. The websocket just forwards data from a MongoDB changeset.

Thanks in advance!

java.lang.IllegalStateException: The remote endpoint was in state [TEXT_PARTIAL_WRITING] which is an invalid state for called method
        at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1274) ~[tomcat-embed-websocket-9.0.63.jar:9.0.63]
        at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.textPartialStart(WsRemoteEndpointImplBase.java:1231) ~[tomcat-embed-websocket-9.0.63.jar:9.0.63]
        at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendPartialString(WsRemoteEndpointImplBase.java:226) ~[tomcat-embed-websocket-9.0.63.jar:9.0.63]
        at org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:49) ~[tomcat-embed-websocket-9.0.63.jar:9.0.63]
        at org.springframework.web.socket.adapter.standard.StandardWebSocketSession.sendTextMessage(StandardWebSocketSession.java:215) ~[spring-websocket-5.3.20.jar:5.3.20]
        at org.springframework.web.socket.adapter.AbstractWebSocketSession.sendMessage(AbstractWebSocketSession.java:106) ~[spring-websocket-5.3.20.jar:5.3.20]
        at org.springframework.graphql.server.webmvc.GraphQlWebSocketHandler$SendMessageSubscriber.hookOnNext(GraphQlWebSocketHandler.java:556) ~[spring-graphql-1.0.0.jar:1.0.0]
        at org.springframework.graphql.server.webmvc.GraphQlWebSocketHandler$SendMessageSubscriber.hookOnNext(GraphQlWebSocketHandler.java:534) ~[spring-graphql-1.0.0.jar:1.0.0]
        at reactor.core.publisher.BaseSubscriber.onNext(BaseSubscriber.java:160) ~[reactor-core-3.4.18.jar:3.4.18]
        at reactor.core.publisher.FluxPublishOn$PublishOnSubscriber.runAsync(FluxPublishOn.java:440) ~[reactor-core-3.4.18.jar:3.4.18]
        at reactor.core.publisher.FluxPublishOn$PublishOnSubscriber.run(FluxPublishOn.java:527) ~[reactor-core-3.4.18.jar:3.4.18]
        at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84) ~[reactor-core-3.4.18.jar:3.4.18]
        at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37) ~[reactor-core-3.4.18.jar:3.4.18]
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
        at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
        at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 13, 2023
@rstoyanchev
Copy link
Contributor

From the stacktrace, you're using Tomcat, Spring MVC, and spring-websocket, i.e. not a WebFlux server.

Aside from that, can you provide the Tomcat version? It's hard to match the exact line number to the Tomcat source. It sounds like there might be some concurrent writing to the socket on the same connection. We do serialize Next messages so it shouldn't happen from that. Could it be the client is sending Ping messages?

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Sep 14, 2023
@fschmuck
Copy link
Author

I am sorry. I must have mixed up something with my dependencies. I will try to switch to webflux.

Yes the client is sending ping messages and the tomcat version seems to be 9.0.63.

@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 labels Sep 14, 2023
@rstoyanchev
Copy link
Contributor

I don't know how easy it is to reproduce, but could you try if turning off pings makes a difference, or reversely you can make them more frequent, and that could get it to occur more often.

Either way, we should make Next and Pong message be sent serially, so I'll schedule this to be done..

@rstoyanchev rstoyanchev added type: bug A general bug and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Sep 14, 2023
@rstoyanchev rstoyanchev added this to the 1.2.3 milestone Sep 14, 2023
@rstoyanchev rstoyanchev self-assigned this Sep 14, 2023
@rstoyanchev
Copy link
Contributor

I've made a fix, but would be great if you could give it a try and confirm. We're releasing this as part of 1.2.3 tomorrow, but until then you can also try with 1.2.3-SNAPSHOT.

@fschmuck
Copy link
Author

Did just a quick test but I think it looks good. Thank you very much!

@rstoyanchev
Copy link
Contributor

Thanks for testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants