Question

I am making an http request which ends up taking more than 8 mins. For me, this long running request work fine. I am able to get a response back to my browser without any issues. (I am located on the same network as the server).

However, for some users, the browser never returns any response. (Note: When the same http request executes in 1 min, these users are able to see the response without any problem)

These users happen to be on another network. And there probably is a firewall or two between their location and the server.

I can see on their fiddler that the request is just sitting there waiting for a response.

I am right now assuming that firewall is killing the idle http connection.. but I am not sure.

If you have any idea why the response never gets back, or why the connection never breaks.. it will be really helpful.

Also: Is it possible to fix this issue by writing an Applet that somehow manages to keep the sending dummy signal to the server, even after having sent (flushed) the request to the server?

Was it helpful?

Solution

The users might be behind a connection tracking firewall/NAT gateway. Such gateways tend to drop the TCP connection when nothing has happened for a period of time. In a custom protocol you could send some kind of heartbeat messags to keep the TCP connection alive, but with HTTP you don't have proper control over that connection, nor does HTTP facilitate what's needed to keep a tcp connection "alive".

The usual way to handle long running jobs initated by an HTTP request is to fire off that job in the background, sending a proper response back to the client immediately and have an applet/ajax request poll the status of that job and returning the result when it's done.

If you need a quick fix, see if you can control any timeouts on the gateways between the server and the user.

OTHER TIPS

Have you considered that the users might be using a browser which has a HTTP timeout which causes the browser to stop waiting for a response after a certain amount of time?

http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html
http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/usingkeepalive.html

If you are using Linux machine try

# cat /proc/sys/net/ipv4/tcp_keepalive_time
  7200
# cat /proc/sys/net/ipv4/tcp_keepalive_intvl
  75
# cat /proc/sys/net/ipv4/tcp_keepalive_probes
  9

# echo 1500 > /proc/sys/net/ipv4/tcp_keepalive_time
# echo 500 > /proc/sys/net/ipv4/tcp_keepalive_intvl
# echo 20 > /proc/sys/net/ipv4/tcp_keepalive_probes
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top