cowboy: session state and connection timeout
Jesper Louis Andersen
Tue Mar 2 17:21:52 CET 2021
On Tue, Mar 2, 2021 at 5:14 AM jdmeta <jdmeta@REDACTED> wrote:
> thanx for the reply leonard.
> agree about the http vs. websocket distinction.
> i started out http because i was hoping i could get to mvp sooner but, as
> you point out, websockets has some advantages.
> since i want to end up there anyway i may bite the bullet and gostraight
> there in mvp.
Websockets have a Ping/Pong setup. You can send a ping frame and expect a
pong frame back. TCP sockets have keepalive as an option you can set on the
The reason for both is that an established TCP connection normally has no
bytes flowing on it at all. So unless one end tries to transmit, the other
end doesn't know the connection is down. I can create a TCP connection, get
the handshake and then not send a byte for 7 days on that connection. It's
still connected and up! TCP keepalive helps with this by sending a packet
every 2 hours or so. And the ping/pong framing in websockets does it even
In general, you can use this to eventually clean up, but note that there
are some lingering that will be present in some corner cases as you don't
know if the other end is slow to respond or gone.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions