vi / websocat

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

Feature Request: Wait until connection has first packet to open other connection #200

Closed LatentLag closed 8 months ago

LatentLag commented 8 months ago

Feature Request:

I have a situation where my left side connection is timing out while waiting for data. The right side connection is up but it doesn't have much going on most of the time.

websocat --connect-wait-until-data tcp:localhost:10022 tcp:other-host:10022

vi commented 8 months ago

tcp:... tcp:... or ws://... ws:///, i.e. connections on both sides, as opposed to listener on the left side and connector on the right side do rarely work well. Maybe the first connection get served, but subsequent connections are trickier.

Currently the closest analogue is foreachmsg: overlay, but that would put each "packet" (in this case, arbitrary chunk of data that recv syscall decided to hand out) into a separate connection.

Making something like waitfordata: overlay which delays activation of the specifier after it can help, but the whole scheme may still be not very reliable.

vi commented 8 months ago

Implemented waitfordata: overlay that works like a hacked autoreconnect: (without actual autoreconnection, but with initial connection delayed).

For example, with websocat -b tcp:127.0.0.1:1234 waitfordata:tcp:127.0.0.1:1235 you can start nc -nvlp 1235 after connection to nc -nvlp 1234 already established, but no data written to it yet.

Please check if it works for you.

LatentLag commented 8 months ago

Thank you, this is working for me.