cowboy: session state and connection timeout

Leonard B leonard.boyce@REDACTED
Wed Feb 24 20:04:19 CET 2021


My understanding would be that:
1. a connection in cowboy is not what you think it is for plain http.
It only exists for the lifespan of the request/response.
2. the _client_ can experience a 'connection timeout', not the server,
since the client can time out attempting to connect to the server

The behavior in websockets(and h2) is a difference story entirely
since that is a persistent/stateful connection between the client and
server.



On Wed, Feb 24, 2021 at 1:12 PM jdmeta <jdmeta@REDACTED> wrote:
>
>
> i'm building a web app using cowboy with mnesia as persistent storage.
> the current version uses http (may move to websockets in the future).
>
> during the lifetime of a user's session, i need to maintain per-user state that is available to all route handlers.
> i plan to initialize this state when a user logs in and write parts of it to persistent storage when the session ends.
> sessions can terminate because of the user logging out or because of a connection timeout.
>
> if a user logs out, then my javascript can hit a route which can write persistent storage.
> if the connection times out, i need to get a message (presumably from cowboy or ranch) to one of my processes so that it can write persistent storage.
>
> i scoured the documentation for cowboy and ranch but didn't find any mention of a mechanism to receive a message on connection timeout.
>
> any help would be appreciated.
> thanx.
>


More information about the erlang-questions mailing list