vi / websocat

Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
MIT License
6.73k stars 259 forks source link

websocat data frame errors #125

Closed gpsmyth closed 3 years ago

gpsmyth commented 3 years ago

Hello, I'm using npm thor as a load tester against websocat

Setup

Any guidance to resolve data frame errors would be appreciated thanks.

vi commented 3 years ago

What request headers does Thor send to Websocat?

Maybe it is using RFC 7692 permessage-deflate and is not noticing that server reply does not accept usage of this extension?

vi commented 3 years ago

(Cannot install thor locally to test myself: command git ls-remote ssh://git@github.com/3rd-Eden/ws.git npm ERR! ERROR: Repository not found.).

gpsmyth commented 3 years ago

Hello, The error logs around websocat I see are

[DEBUG websocat::ws_server_peer] Headers { }
[DEBUG websocat::ws_server_peer] Headers { Sec-WebSocket-Accept: suXLqluylLL4/VDgaMwaBp87NMM=
, Connection: Upgrade
, Upgrade: websocket
, }
[INFO  websocat::ws_server_peer] Upgraded
[INFO  websocat::broadcast_reuse_peer] Reusing
[INFO  websocat::ws_server_peer] Incoming connection to websocket: /
[DEBUG websocat::ws_server_peer] Incoming { version: Http11, subject: (Get, AbsolutePath("/")), headers: Headers { Connection: Upgrade
, Upgrade: websocket
, Host: localhost:8080
, Sec-WebSocket-Version: 13
, Sec-WebSocket-Key: MTMtMTYyMzE0Njk5OTMxMQ==
, Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
, } }
[DEBUG websocat::ws_server_peer] Headers { }
[DEBUG websocat::ws_server_peer] Headers { Sec-WebSocket-Accept: WF4hjD9oXFwU0wGr5jC5Qz/6hBI=
, Connection: Upgrade
, Upgrade: websocket
, }

To install thor I used npm install -g https://github.com/observing/thor

and can run ok via a public server like thor --amount 100 --messages 10 ws://echo.websocket.org

vi commented 3 years ago

Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits

Does websocket library behind thor actually analyse replies (or the lack of replies) to this extension headers? Or does it just turn on e.g. permessage-deflate unconditionally?

gpsmyth commented 3 years ago

Does websocket library behind thor actually analyse replies (or the lack of replies) to this extension headers? Or does it just turn on e.g. permessage-deflate unconditionally?

The closet I see would be: https://github.com/observing/thor/blob/master/mjolnir.js#L94

The underlying node ws library refers to https://www.npmjs.com/package/ws#websocket-compression From there, it sounds that it would be better for client to set: perMessageDeflate option to false

In your experience, what tools would you recommend to load-test against websocat (as a simple server) if thor cannot fulfil here (My preference was light-weight open-source).

On another thought, when running websocat -vvv ws://echo.websocket.org - is it possible to observe the perMessageDeflate option and what is it as I didn't see in logs?

vi commented 3 years ago

What exactly do you want to load-test? What Websocat command line do you use? Just websocat -s or something more fancy (like running child processes from Websocat or UDP interconnection, etc.)?

How do you expect the load test to work? Does the load testing tool expect some replies to its Websocket messages?

Some limited and simple load testing may be done by Websocat itself (although it is not designed to be used as a load testing tool, nor it is a good methodology to measure Websocat with Websocat).


I tried installing thor locally, but it does not produce any runnable executable in npm prefix. I don't typically use NodeJS and maybe I am doing something wrong although.

vi commented 3 years ago

On another thought, when running websocat -vvv ws://echo.websocket.org - is it possible to observe the perMessageDeflate option and what is it as I didn't see in logs?

Current version of Websocat does not support per message deflate neither as client nor as server, so you won't see this option. Future version (websocat3) will be based on another Websocket library and is likely to support the extension.

vi commented 3 years ago

Maybe you can modify thor and turn off message compression (and other extensions). That may workaround the issue.

Proper fix would be to make that websocket library more standards compliant and avoid activating extensions when server does not declare support for them.

gpsmyth commented 3 years ago

Thanks for your comments / feedback. I'll close as unsolved.