Open josh-endries opened 1 year ago
Indeed, autoreconnect:reuse:
does not make much sense. Maybe I'll implement a lint that shows a warning when trying to use such combination.
My ultimate use case is periodically (e.g. every second or via tail) reading a file, filtering lines, and dumping results to a (real) server. I'd rather not reconnect every second so I was experimenting with reuse/reconnect to act as a pseudo-persistent connection.
Something like
tail -f some_file.txt | websocat -ut - ws://127.0.0.1:12345
? Why do you need reuse:
?
Also note that reuse:
have two modes: reuse-raw:
and broadcast:
(the default). They have different buffering behaviour and sometimes single client mode (raw) works better.
I was originally thinking of sending frequent batches via cron, or a script loop, and reuse
seemed like a way to try to keep connections open instead of opening a new one for every batch. With a streaming approach it's not needed.
I'm not sure if this is intended and I'm just using it wrong, but I ran into what seems like an infinite loop bug due to overlay order (hopefully that's the right terminology, this is my first time using websocat).
Repro:
It never reconnects.
However, if I run the proxy this way, with
reuse
andautoreconnect
flipped, it works mostly as expected:After aborting and restarting the server, the client's events usually get through. Sometimes the first batch of lines I send don't make it (or partially). I suspect this loop is because the overlays just decorate each other, so maybe it makes sense that this fails, but I'm not entirely sure if I should expect the first case to fail so I wrote this up.
I wish there was a way, from a client perspective, to know if events made it or not, so I could know to retry sending them. For example, setting an exit code if it can't connect, but this might be tough with buffering.
My ultimate use case is periodically (e.g. every second or via tail) reading a file, filtering lines, and dumping results to a (real) server. I'd rather not reconnect every second so I was experimenting with reuse/reconnect to act as a pseudo-persistent connection.