Closed AntonioSun closed 4 months ago
By default WebSocat, when sees EOF on stdin, sends a WebSocket close frame, then waits for possible final replies, prints them, then exits.
-n
opts out from sending the close frame (you may need to use this one).
-E
makes it exit immediately when stdin is closed, without waiting for replies at all.
Note that by default WebSocat is in text and line-based mode, so number of WebSocket text messages sent should be equal to number of lines on input.
Thanks!
Another influential option (for servers which fail to reply if they receive the close frame immediately after request message) is -1
(--one-message
):
$ echo '{"email":"user1@mail.com","password":"test"}' | websocat -n -1 ws://ws.vi-server.org/mirror/ | wc
1 1 45
$
Also you can somewhat simulate a -q
option of netcat like this:
$ { echo '{"email":"user1@mail.com","password":"test"}'; sleep 1; } | /opt/websocat -E ws://ws.vi-server.org/mirror/ | wc
(1 second delay)
1 1 45
$
Does
websocat
support accepting commands from pipe?JFTA,
nc
can, in two different ways:nc -q -1 host port
:-q seconds after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever.
or,
echo command | netcat host port -
Thanks for considering.