Browse files

#41 - don't disconnect websockets if 'receiver' doesn't come back 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...
1 parent 0aca923 commit d97f364b8d5ad3191170c7c7dd2dd2a159dc82a0 @majek majek committed Nov 26, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/sockjs_cowboy_handler.erl
@@ -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

0 comments on commit d97f364

Please sign in to comment.