[erlang-questions] Mochiwebsockets was Re: Long polling

Gleb Peregud <>
Fri Jul 20 11:54:30 CEST 2012

On Fri, Jul 20, 2012 at 10:59 AM, Gordon Guthrie <> wrote:
> So 30 secs is the right time for a long connection - at the moment we
> use 600 secs and get intermittent disconnection problems - usually
> when using a mobile internet connection -  mebbies I should dial it
> down to 30 secs.

Alternatively you could leave it at 600 secs and employ reconnect
mechanism, which tries to reconnect few times (and adjusting timeout
value for next attempt adaptively) before giving up and returning an
error. It may be better solution for 90% of your users, but will still
work for users with bad proxies/connection. But be aware that some
proxies (or bad internet connection) may drop those connections
silently and reconnect mechanism won't work since broken connection
won't be detected. So it's a tradeoff between robust solution for
everyone with high bandwidth consumption and low bandwidth consumption
for 99% of users and broken service for 1% of users.

In my setup where I'm using SockJS I am employing a heartbeat
mechanism over streaming connections. I.e. SockJS sets up a persistent
connection and server sends one byte of information to the user very
30 seconds (in case of polling connections it is of course much higher
than 1 byte, but for streaming connections, which are prevalent it's
just one byte) and client checks if he got heartbeat to detect
silently dropped connection in at most 30 seconds.

Oh, and mobile users are often connected via some sort of proxy
(Blackberry, Opera Mini/Mobile, some ISPs use transparent caching as

More information about the erlang-questions mailing list