Skip to content

Commit 0485c18

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 b19ead6 commit 0485c18

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
@@ -40,8 +40,10 @@ websocket_init(_TransportName, Req,
4040
Service = #service{logger = Logger, hib_timeout = HibTimeout}) ->
4141
Req0 = Logger(Service, {cowboy, Req}, websocket),
4242

43+
Service1 = Service#service{disconnect_delay = 5*60*1000},
44+
4345
{Info, Req1} = sockjs_handler:extract_info(Req0),
44-
SessionPid = sockjs_session:maybe_create(undefined, Service, Info),
46+
SessionPid = sockjs_session:maybe_create(undefined, Service1, Info),
4547
{RawWebsocket, {cowboy, Req3}} =
4648
case sockjs_handler:get_action(Service, Req1) of
4749
{{match, WS}, Req2} when WS =:= websocket orelse

0 commit comments

Comments
 (0)