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

A MessageTooLargeException doesn't close a WebSocket connection #9895

Closed
raymank26 opened this issue Jun 8, 2023 · 1 comment · Fixed by #9903
Closed

A MessageTooLargeException doesn't close a WebSocket connection #9895

raymank26 opened this issue Jun 8, 2023 · 1 comment · Fixed by #9903
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@raymank26
Copy link

raymank26 commented Jun 8, 2023

Jetty version(s)

11.0.15

Java version/vendor (use: java -version)

openjdk version "11.0.11" 2021-04-20

OS type/version

MacOs Ventura (13.2.1)

Description

When org.eclipse.jetty.websocket.core.internal.messages.StringMessageSink#accept is called with a Frame larger than configured the MessageTooLargeException is thrown. This behavior is expected.

The problem is that in this state the WS connection is not closed which is not aligned with org.eclipse.jetty.websocket.api.WebSocketPolicy JavaDoc - Text messages over this maximum will result in a close code 1009 {@link StatusCode#MESSAGE_TOO_LARGE}

The interesting thing is that setting WebSocketPolicy#setMaxTextMessageSize with a value lower than the incoming text message solves the problem. The error is propagated as expected. But using a default value doesn't leads to this problem.

Right after the exception in DEBUG logging mode, the following information is printed:

2023-06-08 22:41:34 [JettyServerThreadPool-35] DEBUG o.e.j.w.c.i.PerMessageDeflateExtension - Decompress finished: true CONTINUATION@58971e91[len=0,fin=false,rsv=000,m=null]HeapByteBuffer@791fd82d[p=0,l=0,c=8192,r=0]={<<<>>>xWZKFpBac...\x00\x00\x00\x00\x00\x00\x00}
2023-06-08 22:41:34 [JettyServerThreadPool-35] DEBUG o.e.j.w.c.i.WebSocketConnection - moreDemand? d=0 fp=true RetainableByteBuffer@112d1841{DirectByteBuffer@542f8ca0[p=4096,l=4096,c=4096,r=0]={/\x88\x15af\x92\xEc\xCd\xA9...VS\x82K\xB2,w<<<>>>},r=2} WebSocketConnection@5d4ab1ad::SocketChannelEndPoint@4c6641e8[{l=/0:0:0:0:0:0:0:1:8839,r=/0:0:0:0:0:0:0:1:64564,OPEN,fill=-,flush=-,to=6347/30000}{io=0/0,kio=0,kro=1}]->[WebSocketConnection@5d4ab1ad[SERVER,p=Parser@f16d1a1[s=FRAGMENT,c=0,o=0x0,m=1dD1217f,l=36967],f=Flusher@71234240[IDLE][queueSize=0,aggregate=null],g=org.eclipse.jetty.websocket.core.internal.Generator@3769740]]
2023-06-08 22:41:34 [JettyServerThreadPool-35] DEBUG o.e.j.u.t.ReservedThreadExecutor - ReservedThread@1a3a4772{RUNNING,thread=Thread[JettyServerThreadPool-35,5,main]} was=RUNNING next=RESERVED size=0+2 capacity=12
2023-06-08 22:41:34 [JettyServerThreadPool-35] DEBUG o.e.j.u.t.ReservedThreadExecutor - ReservedThread@1a3a4772{RESERVED,thread=Thread[JettyServerThreadPool-35,5,main]} waiting ReservedThreadExecutor@6dc1484{reserved=2/12,pending=0}

onWebSocketClose/onWebSocketError methods are not called. From the client's perspective (Chrome browser in my case) the connection is not closed either.

Searching through relevant issues I can mention #7351 as it has similar symptoms.

From my point of view PerMessageDeflateExtension should somehow handle the underlying exception (close the connection) but it does nothing like that in this case.

How to reproduce?

A reproducer project is available at https://github.com/raymank26/jetty-11.0.15-websocket-permessage-deflate

@raymank26 raymank26 added the Bug For general bugs on Jetty side label Jun 8, 2023
@raymank26 raymank26 changed the title A MessageTooLargeException doesn't close WebSocket connection A MessageTooLargeException doesn't close a WebSocket connection Jun 8, 2023
@lachlan-roberts lachlan-roberts self-assigned this Jun 13, 2023
lachlan-roberts added a commit that referenced this issue Jun 13, 2023
…ateExtension

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@lachlan-roberts
Copy link
Contributor

Thanks for the report, I put up PR #9903 which should fix this issue.

lachlan-roberts added a commit that referenced this issue Jun 15, 2023
Issue #9895 - ensure callback is failed after error in PerMessageDeflateExtension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
2 participants