views:

369

answers:

3

At work, we have a client-server system where clients submit requests to a web server through HTTP. The server-side processing can sometimes take more than 60 seconds, which is the proxy timeout value set by our company's IT staff and cannot be changed. Is there a way to keep the HTTP connection alive for longer than 60 seconds (preferably for an arbitrarily long period of time), either by heartbeat messages from the server or the client?

I know there are HTTP 1.1 persistent connections, but that is not what I want.

Does HTTP have a keep-alive capability, or would this have to be done at the TCP level through some sort of socket option?

+2  A: 

This should get you started.

RarrRarrRarr
A: 

Assuming you control both sides of the system, you can fake it by sending data back and forth periodically to keep the session from idling out -- most browsers won't terminate a connection as long as data is moving.

As a general suggestion, though, you're much better off re-designing the system so that the client submits a job request and then periodically queries (via Ajax) to see if it's completed. The Ajax queries can delay a while and the server can respond either when it has an affirmative status, or when the timeout period is near to elapsing. If the status-update request times out for some reason (timing errors or whatnot), the client simply re-submits it with no harm done and no visible disruption from the user's perspective.

Dan Story
A: 

Just have your server send a trickle of no-op data while it's doing the processing - if the result is HTTP, then something like:

<!-- keepalive -->

sent every 10 seconds should do.

caf