[erlang-questions] Mochiwebsockets was Re: Long polling

Gordon Guthrie <>
Thu Jul 19 23:02:42 CEST 2012


Gleb

The app is built on mochiweb - I inspect the request and route it to a
handler. So I would need to bind the server part of the library to the
that particular HTTP request.

Bullet is designed to work in Cowboy,
Socket.io has its own Erlang server
SockJS is designed to be web-framework agnostic but the examples are
all in Cowboy

As I understand it - these socket solutions have a code the server
side and client side which ping traffic backwards and forwards and
keep a 'permanent' connection open - and the higher level libraries
can then write to the socket as if there was a stateful synchronous
connection.

So to use one of these I would need to pick a particular client JS
library and then write my own handler to use on the socket in mochiweb
(or cut one out from one of the existing servers...)

Has anyone done stuff on getting it into mochiweb?

Gordon


On 17 July 2012 16:01, Gleb Peregud <> wrote:
> On Tue, Jul 17, 2012 at 4:57 PM, Gordon Guthrie <> wrote:
>> Folks
>>
>> I am building a softphone which needs to register with the server to say "I
>> am available" for incoming calls.
>>
>> So it makes an HTTP POST request to the server and that notifies the
>> softphone gen_srv that is is available.
>>
>> At that point I leave the TCP request hanging on a receive waiting for a
>> notification that the socket has been torn down (and which point it
>> unregisters the phone).
>>
>> My question is: how long can I leave the request up? Infinity? or do I need
>> to have a timeout/reregister cycle setup?
>
> You have to cycle it. Some proxies timeout connections after 30
> seconds, some after 45 some after 60. It is very tricky to get it
> right for all browsers and all platforms. Generally if you want a
> robust solution use something like SockJS or Socket.IO or Bullet.



More information about the erlang-questions mailing list