vi / websocat

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

REQUEST: Specify unexpected status code #55

Closed thijsvandien closed 4 years ago

thijsvandien commented 4 years ago

When the server gives an error, the program indicates:

websocat: WebSocketError: Received unexpected status code

It would be nice if it would specify what the status code actually was, e.g.:

websocat: WebSocketError: Received unexpected status code (404)

vi commented 4 years ago

Indeed, the code is not visible even in verbose mode.

Probably should be in Websocat 2.0

janpieper commented 4 years ago

Any status on this issue? I had the same issue today and it took me some time to find out what's wrong.

vi commented 4 years ago

The status is like "waiting for inspiration to resume work on Websocat in general".

It may happen if/when I need to advance Websocat for myself for some need.


It would be reasonable to rewrite Websocat for a better architecture and newer dependencies, but the lack of real tests makes it tricky to do such rewrite without breakages. And just writing tests is typically boring and I instead switch to other project when I think about it too much...

(Also I'm not sure if Websockets in general would have a bright future in future HTTP/3 / QUIC world - one of reasons I have recently added crude SSE support to Websocat).


Maybe I can just merge & publish this particular change ahead of big changes, as it looks like there is some popular support for this change.

vi commented 4 years ago

Published websocket v0.26.1 with pull request above merged.

Next step is to build and upload websocat (probably 1.6.0, the 2.0 idea may be worth abandoning).

vi commented 4 years ago

Published a release "v1.6.0" (including pre-built artifacts) with this issue resolved.

$ websocat ws://127.0.0.1:1234/
websocat: WebSocketError: Received unexpected status code (333 <unknown status code>)
websocat: error running
$ nc -lp 1234
GET / HTTP/1.1
Host: 127.0.0.1:1234
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 5+hWvcjTmn5dQGch4F0doA==

HTTP/1.1 333 QQQ^M
^M