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

logging proxied traffic #81

Open emiddleton opened 4 years ago

emiddleton commented 4 years ago

Is it possible to log traffic being proxied to a file? I am trying to debug json-rpc over a websocket and would like to be able to see what is being sent and received.

vi commented 4 years ago

Splitting streams to two specifies is not currently supported.

Do you maybe have an idea for versatile and composable command line syntax for it and semantics of what exactly would happen?

vi commented 3 years ago

Note that now there is a log: overlay which can be used to log things to stderr (which can be redirected to a file).

alexeycrystal commented 2 years ago

websocat -B 500000 -v -v --text log:ws-listen:127.0.0.1:9943 log:ws://127.0.0.1:9944

this is just a small example with the websocat 1.8.0 version. Don't forget to use your personal ports e.t.c. this one is just proxing all data from 9943 port to 9944 and logs them both. p.s. I have also chosen a huge buffer size

vi commented 2 years ago

@alexeycrystal Note that such proxy would mangle binary WebSocket messages, converting them into text ones and maybe changing some bytes (such as newlines).

To be able to forward both text and binary WebSocket messages reliably you need --base64, --binary-prefix, --text-prefix and maybe --base64-text options.