Skip to content

Commit

Permalink
sockjs#41 - don't disconnect websockets if 'receiver' doesn't come ba…
Browse files Browse the repository at this point in the history
…ck in 5 seconds

Timeout mechanism is broken with regard to websockets. cowboy process might be overloaded by incoming messages (And session not being able to pick them up quickly enough). If that happens, it's quite likely that session process will receive a timeout after 5 seconds of not having the 'reply' call. This seems to be less of a big deal for non-ws transports as they don't neccesairly come via a signle bottleneck process - receiver is different than sender.
  • Loading branch information
majek authored and gebi committed Apr 10, 2013
1 parent 4575a16 commit bedc871
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sockjs_cowboy_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ websocket_init(_TransportName, Req,
Service = #service{logger = Logger, hib_timeout = HibTimeout}) ->
Req0 = Logger(Service, {cowboy, Req}, websocket),

Service1 = Service#service{disconnect_delay = 5*60*1000},

{Info, Req1} = sockjs_handler:extract_info(Req0),
SessionPid = sockjs_session:maybe_create(undefined, Service, Info),
SessionPid = sockjs_session:maybe_create(undefined, Service1, Info),
{RawWebsocket, {cowboy, Req3}} =
case sockjs_handler:get_action(Service, Req1) of
{{match, WS}, Req2} when WS =:= websocket orelse
Expand Down

0 comments on commit bedc871

Please sign in to comment.