-
Notifications
You must be signed in to change notification settings - Fork 529
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
Invalid WebSocket frame: invalid status code 0 #2679
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
v20.11.0
Platform
Linux ndndev 6.1.0-17-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.69-1 (2023-12-30) x86_64 x86_64 x86_64 GNU/Linux
Subsystem
WebSocket
What steps will reproduce the bug?
main.mjs
package.json
How often does it reproduce? Is there a required condition?
This bug always happens when the above snippet is invoked with
--experimental-websocket
flag.What is the expected behavior? Why is that the expected behavior?
The expected behavior may be obtained by importing
WebSocket
from ws package.The console log is:
ws-websocket.pcapng.zip is the packet capture of this execution.
When the WebSocketServer closes the client connection in Frame 8, the WebSocket client responds with a Close frame in Frame 10.
Close frame from ws WebSocket client is encoded as:
Notably, there isn't a payload field in this packet.
What do you see instead?
The console log is:
While the error appears to come from ws, it is caused by incorrect packet encoding by Node.js native WebSocket implementation.
node-websocket.pcapng.zip is the packet capture of this execution.
When the WebSocketServer closes the client connection in Frame 8, the WebSocket client responds with a Close frame in Frame 10.
Close frame from Node.js native WebSocket is encoded as:
Notably, there's a payload containing a Status code that is zero.
Additional information
According to RFC 6455 section 5.5.1:
According to RFC 6455 section 7.4.2:
Node.js native WebSocket client has violated the protocol by sending an unassigned value as the status code.
The text was updated successfully, but these errors were encountered: