wscat
wscat copied to clipboard
Keep-Open Option
Hi -
I have a use case for wscat, where I need to send a message to a remote server, and then leave the connection open, so I can receive the responses. As such, I added a simple "keep-open" flag, which doesn't close the web socket or exit the process after the console is closed. This allows wscat to be used in conjunction with echo/cat/etc and an input pipe:
echo '{"type":"message-type"}' | wscat --keep-open -connect localhost:80
Creating a pull request in case this might be useful to others.
Cheers, -Courtland
It makes sense, should the same be done for the server (--listen)?
I just tested this out and can't seem to make it work.
To be clear, the keep-open works, but not the piping stdin
I guess this doesn't work because 'line' events are ignored before the WebSocket is open. To make it work with the current implementation we should probably buffer them.