Sunday, April 1, 2018

Sockjs/socketio disconnect delay behind apache proxy

Leave a Comment

I need to handle users disconnecting from my sockjs application running in xhr-polling mode. When I connect to localhost, everything works as expected. When I put apache between nodejs and browser, I get ~20 sec delay between closed browser and disconnect event inside nodejs. My apache proxy config is following:

<Location />   ProxyPass http://127.0.0.1:8080/   ProxyPassReverse http://127.0.0.1:8080/ </Location> 

The rest of the file is default, you can see it here. I tried playing with ttl=2 and timeout=2 options, but either nothing changes, or I get reconnected each 2 seconds without closing browser. How can I reduce additional disconnect timeout, introduced, but apache, somewhere in its defaults?

1 Answers

Answers 1

It's possible that your Apache server is configured to use HTTP Keep Alive which will keep a persistent connection open. In that case I would try disabling KeepAlive, or lowering the KeepAliveTimeout setting in your Apache configuration to see if this solves the problem.

If that doesn't work, I would also take a look at netstat and see what is the status of each socket and start a root cause analysis. This chart gives is the TCP state machine and can tell you where each connection is. Wireshark can also give you some information on what is going on.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment