wscat icon indicating copy to clipboard operation
wscat copied to clipboard

Keep-Open Option

Open Frugality opened this issue 8 years ago • 4 comments

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

Frugality avatar May 22 '17 19:05 Frugality

It makes sense, should the same be done for the server (--listen)?

lpinca avatar May 23 '17 05:05 lpinca

I just tested this out and can't seem to make it work.

nwwells avatar Dec 06 '17 10:12 nwwells

To be clear, the keep-open works, but not the piping stdin

nwwells avatar Dec 06 '17 11:12 nwwells

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.

lpinca avatar Dec 06 '17 13:12 lpinca