WebSocket - full-stream being disconnected at regular interval
Opened this issue · 3 comments
A small question, the WS connection to the full-stream disconnects with code 1000 (successful close) at regular interval. I used various WS libraries and I have the same behaviour. I looked into web.ex but cannot find code triggering the close.
I use the latest 26dff90 and used the following Elixir version
Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:24:24] [ds:24:24:10] [async-threads:1]
Elixir 1.9.1 (compiled with Erlang/OTP 22)
Is it a common behaviour or a bug?
Complementary information, the Python client using WS from https://github.com/CaliDog/certstream-python/blob/master/certstream/core.py#L20 works as expected. I suppose it's the heartbeat.
Hi @adulau sorry for the delay in getting back to you.
A small question, the WS connection to the full-stream disconnects with code 1000 (successful close) at regular interval. I used various WS libraries and I have the same behaviour. I looked into web.ex but cannot find code triggering the close.
Yep, Erlang's cowboy webserver (which certstream uses) will disconnect clients that are idle after I think it's 60s. Basically it can't tell if a client is idle or if something else has gone wrong since we don't have a message acknowledgement system (which would be quite some overhead performance wise).
The simple solution is to send some data to the server at a specific interval, and the server will basically just ignore it, though it will stop your disconnect issue.
Unfortunately I think our support for heartbeats is a bit scattered at the moment, I went to scope out what it'd take for golang for example and it seemed like a non-trivial effort.
That said, I'm curious what language you're talking to certstream from, and if it'd make sense to make your language a supported one as well.
Cheers!
Ah here we go, check out idle_timeout
- https://ninenines.eu/docs/en/cowboy/2.5/manual/cowboy_websocket/#_opts. I think originally I set this value really high on the server but as you can imagine never cleaning up idle sockets can lead to stability issues :).