Skip to content

Commit d97f364

Browse files
committed
#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.
1 parent 0aca923 commit d97f364

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/sockjs_cowboy_handler.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ terminate(_Req, _Service) ->
3333
websocket_init(_TransportName, Req, Service = #service{logger = Logger}) ->
3434
Req0 = Logger(Service, {cowboy, Req}, websocket),
3535

36+
Service1 = Service#service{disconnect_delay = 5*60*1000},
37+
3638
{Info, Req1} = sockjs_handler:extract_info(Req0),
37-
SessionPid = sockjs_session:maybe_create(undefined, Service, Info),
39+
SessionPid = sockjs_session:maybe_create(undefined, Service1, Info),
3840
{RawWebsocket, {cowboy, Req3}} =
3941
case sockjs_handler:get_action(Service, Req1) of
4042
{{match, WS}, Req2} when WS =:= websocket orelse

0 commit comments

Comments
 (0)