[erlang-questions] Awkward timeout behavior in Cowboy Websockets

Noah Silverman noah@REDACTED
Wed Nov 14 12:12:01 CET 2018


Hi Loic,

Actually using Cowboy 2.5, and following examples examples directly from the user guide on ninenines website.




--
Noah 



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Wednesday, November 14, 2018 3:07 PM, Loïc Hoguin <essen@REDACTED> wrote:

> Sounds like you are using Cowboy 1.x, in which case it'll be simpler to
> fork and fix directly.
> 

> Someone mentioned not too long ago that sending 1001 for timeout closes
> might be a good idea. I'm probably OK with that, but nobody's opened a
> ticket or PR so the idea got lost in the back of my mind.
> 

> Cheers,
> 

> On 11/14/18 3:09 AM, Noah Silverman wrote:
> 

> > Hello,
> > When using Cowboy Websockets, I am seeing strange behavior during a timeout.
> > As per the documentation, when upgrading a connection to websocket,
> > there is an optional parameter for idle_timeout (defaults to 60000).
> > This works, and the connection does close after the correct number of
> > seconds.
> > However, there is no timeout message sent to the client, and I don't see
> > a way to send one.
> > There is a websocket_terminate/3 callback.  However, the documentation
> > seems to indicate that function is called after the connection is closed.
> > Looking in the source code for cowboy_websocket.erl, I see on lines
> > 417-429 the different ways to close the socket.  A "stop" and a
> > "timeout" are handled exactly the same, with a generic close of 1000.
> > So, no way for the client to know that idle_timeout was triggered.
> > We have a service that streams data to a browser client.
> > 

> > -   The browser connects and requests a subscriptions to a feed
> > -   We then stream that data continuously.
> > -   No further action is required from the client, except a ping to keep
> >     the connection open.
> >     

> > 

> > However, if the client doesn't ping, the connection will close
> > silently.  There is no indication to the client that they were dropped
> > due to timeout.
> > Is there a way to remedy this?  Perhaps some way to have Cowboy send a
> > "timeout message" when idle_timeout triggers?
> > Thank You,
> > --
> > Noah
> > 

> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
> 

> --
> 

> Loïc Hoguin
> https://ninenines.eu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: publickey - noah@REDACTED - 0xBCEFA873.asc
Type: application/pgp-keys
Size: 3136 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20181114/11ae9c6d/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 855 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20181114/11ae9c6d/attachment-0001.bin>


More information about the erlang-questions mailing list