Skip to content

Commit

Permalink
#41 - don't disconnect websockets if 'receiver' doesn't come back in …
Browse files Browse the repository at this point in the history
…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 committed Dec 14, 2012
1 parent 0aca923 commit d97f364
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 @@ -33,8 +33,10 @@ terminate(_Req, _Service) ->
websocket_init(_TransportName, Req, Service = #service{logger = Logger}) ->
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 d97f364

Please sign in to comment.