vi / websocat

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

Error on redirect to /dev/null #89

Open andye2004 opened 4 years ago

andye2004 commented 4 years ago

I want to be able to run websocat and redirect incoming messages to /dev/null, however when doing this I get an error from websocat, e.g.

$> echo 'something' | websocat -n ws://localhost:9002/something > /dev/null 
websocat: Invalid argument (os error 22)
websocat: error running
$> 
vi commented 4 years ago

Which platform is it? Is it Mac?

On Linux, running echo 'something' | websocat -n ws://echo.websocket.org > /dev/null does not result in error.

Does error happen before or after sending the message? Does this WebSocket server begin with sending a message or waits for client's message first?

andye2004 commented 4 years ago

Hi @vi it is actually running on mac, yes. That said I'm only developing on mac but intend to run on linux so if the error is not present on CentOS then we should be good.

The server being connected to awaits a 'subscription' message from the client before sending anything back through the socket.

vi commented 4 years ago

Then maybe this can be a workaround:

echo 'something' | websocat -t -n ws://localhost:9002/something threadedstdio: > /dev/null

I'm thinking about making threadedstdio: the default on Mac (like it is a default on Windows). There is already another bug related to async stdin on Mac.