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

Websockets 1002 Unknown opcode: 7 with Jetty 10.0.24 on Mac, but not Linux, Win10 - with test case attached #12390

Open
afarber opened this issue Oct 15, 2024 · 15 comments
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@afarber
Copy link
Contributor

afarber commented Oct 15, 2024

Jetty version(s)
12.0.14

Java version/vendor (use: java -version)
javac 23

OS type/version
macOS Sequoia

How to reproduce?

Please run the ./test-mac.sh script in the attached zip archive and then open the URL http://127.0.0.1:8080/en/ in Edge or Firefox browser on macOS and look at the browser console:

image

jetty-mac-opcode-7.zip

The test Javascript code is in the file jetty-mac-opcode-7/my-servlet/src/main/resources/index.html

Thank you

@afarber afarber added the Bug For general bugs on Jetty side label Oct 15, 2024
@afarber
Copy link
Contributor Author

afarber commented Oct 15, 2024

Also, I tested downgrading to Jetty 10.0.22 and 10.0.20, but the above test case fails there too.

@sbordet
Copy link
Contributor

sbordet commented Oct 15, 2024

@afarber sorry, but Jetty 10/11 are at end of community support:

Please upgrade to Jetty 12 and report back if you still have the problem.

@afarber
Copy link
Contributor Author

afarber commented Oct 18, 2024

Yes, this bug seems to be in Jetty 12 too:

2024-10-18 22:19:54.608:WARN :oe.WebSocketChatServlet$ChatWebSocket:qtp369241501-43: Unhandled Error: Endpoint org.example.WebSocketChatServlet$ChatWebSocket : org.eclipse.jetty.websocket.api.exceptions.ProtocolException: Unknown opcode: 7

To reproduce:

mkdir /Users/afarber/src/jetty-questions/test-demo/jetty.base
cd /Users/afarber/src/jetty-questions/test-demo/jetty.base
java -jar /Users/afarber/src/jetty-questions/jetty-home-12.0.14/start.jar --add-modules=server,http,ee10-deploy,ee10-demos
java -jar /Users/afarber/src/jetty-questions/jetty-home-12.0.14/start.jar

And then just navigate to the URLs:

I have tried both Edge and Safari browsers on macOS 15

@afarber
Copy link
Contributor Author

afarber commented Oct 18, 2024

screenshot

@joakime
Copy link
Contributor

joakime commented Oct 18, 2024

@afarber can you report the HTTP Upgrade Request and Response headers from your developer tools on safari and edge?
We want to see the details on how the browser attempts to negotiate the websocket endpoint.

@joakime
Copy link
Contributor

joakime commented Oct 18, 2024

Noting the websocket bugs listed for webkit (used by both edge and safari on macos)

Also, what is the exact versions listed for your safari and edge browsers?

@afarber
Copy link
Contributor Author

afarber commented Oct 18, 2024

Microsoft Edge
Version 129.0.2792.89 (Official build) (arm64)

Safari
Version 18.0.1 (20619.1.26.31.7)

Firefox
131.0.3 (aarch64)

image

@afarber
Copy link
Contributor Author

afarber commented Oct 18, 2024

Edge request headers:

GET ws://127.0.0.1:8080/ee10-test/jetty.websocket/jetty.websocket/ HTTP/1.1
Host: 127.0.0.1:8080
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0
Upgrade: websocket
Origin: http://127.0.0.1:8080
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: en-GB,en;q=0.9,en-US;q=0.8,de;q=0.7,ru;q=0.6,de-DE;q=0.5
Cookie: visited=yes
Sec-WebSocket-Key: N5B6trQcdmryzryWUqdZyQ==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Protocol: chat

Edge response headers:

HTTP/1.1 101 Switching Protocols
Server: Jetty(12.0.14)
Vary: Accept-Encoding
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Extensions: permessage-deflate
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: IREMkPTB9YEubw1Inc5u5EcngRY=

@afarber
Copy link
Contributor Author

afarber commented Oct 18, 2024

Safari request headers:

Cache-Control: no-cache
Connection: Upgrade
Origin: http://127.0.0.1:8080
Pragma: no-cache
Sec-Fetch-Dest: websocket
Sec-Fetch-Mode: websocket
Sec-Fetch-Site: same-origin
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: zzKJ9wqRdw9v59uE3NyWKQ==
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Version: 13
Upgrade: websocket
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Safari/605.1.15

Safari response headers:

Connection: Upgrade
Sec-WebSocket-Accept: h+N0SkVKm0GK9waNAkYliyZCIaE=
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Protocol: chat
Server: Jetty(12.0.14)
Upgrade: websocket
Vary: Accept-Encoding

@joakime
Copy link
Contributor

joakime commented Oct 18, 2024

Yup, you have websocket compression via the permessage-deflate extension in both cases.
Something the webkit bugs report as an issue in both cases.

If you use something like Chrome on that same Mac, does it also fail? (it has a different underlying web technology codebase).

Oddly, the reported browser, in both cases is "Macintosh; Intel Mac OS X 10_15_7", which isn't a M1 mac.
But that's just a strange thing I noticed, doesn't really matter, or mean anything.

@afarber
Copy link
Contributor Author

afarber commented Oct 18, 2024

Firefox request headers:

GET /ee10-test/jetty.websocket/jetty.websocket/ HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
Prefer: safe
Sec-WebSocket-Version: 13
Origin: http://127.0.0.1:8080
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: HGAIInfKTFMKRKdqe0jY+g==
Connection: keep-alive, Upgrade
Cookie: visited=yes
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: websocket
Sec-Fetch-Site: same-origin
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket

Firefox response headers:

HTTP/1.1 101 Switching Protocols
Server: Jetty(12.0.14)
Vary: Accept-Encoding
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Extensions: permessage-deflate
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: mdsEAZ3aa4Mb2Yv5DDFP15eBRxs=

@afarber
Copy link
Contributor Author

afarber commented Oct 18, 2024

Sorry, I cannot install Chrome, because I do not want them to track my Android dev account or ban Google/Android phone accounts of me and my relatives.

They already banned my AdSense account for nothing maybe 15 years ago and the experience was bad.

@joakime
Copy link
Contributor

joakime commented Oct 18, 2024

I only have a Macbook Pro from 2012, can't upgrade it to Seqouia.

Seeing as websocket compression is just continually hosed on Safari and webkit, it's probably time to implement a User-Agent based compression logic at the low level websocket negotiation code.

We are not the only group struggling with webkit issues with websocket compression.

The three User-Agents look like ...

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:131.0) Gecko/20100101 Firefox/131.0
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0.1 Safari/605.1.15
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0

I think we should look for either Mac OS X or AppleWebKit in the User-Agent as a trigger to disable compression negotiation.

@lachlan-roberts what do you think about having a configurable for something like "websocket.compression.webkit.enabled=false" as a default.

@joakime
Copy link
Contributor

joakime commented Oct 18, 2024

Ya know, maybe a WebkitDisableWebsocketCompressionRule makes sense too.
It would strip out the Sec-WebSocket-Extensions: permessage-deflate from the client side.

Similar to what we used to have back in Jetty 9, with the MsieSslRule.

It could be enabled rather quickly from a jetty-home module too.

@afarber
Copy link
Contributor Author

afarber commented Oct 19, 2024

Wouldn't AppleWebKit also match iOS Safari?

I have tried with my iPhone 13 and the demo seems to work there:

image

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
Status: No status
Development

No branches or pull requests

4 participants