[erlang-questions] Mochiwebsockets was Re: Long polling

Gordon Guthrie <>
Fri Jul 20 00:42:40 CEST 2012


Loïc

So I would then have 3 things running my application - mochiweb,
cowboy and a socket server...

I am a big fan of avoiding code at all costs :(

Given that I have a simple understood use case, mebbies I don't need a
fully featured socket server, mebbies I need to put a simple
client-driven registration system...

Gordon

On 19 July 2012 23:24, Loïc Hoguin <> wrote:
> Or you can replace Mochiweb by Cowboy+Mochicow
> (https://github.com/benoitc/mochicow) and use Cowboy's routing to redirect
> to your websocket handler or your mochiweb code.
>
>
> On 07/19/2012 11:02 PM, Gordon Guthrie wrote:
>>
>> 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.
>>
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
>
> --
> Loďc Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
>



More information about the erlang-questions mailing list