How long does the Tropo script keep the HTTP socket/connection open

JustinDupree -

By default, when you make an HTTP/1.1 request (the default version for at least a decade, so very likely what you're using), the server will keep the TCP connection alive for a short period of time, just in case you make any follow-on requests, the TCP setup time won't be incurred again.

The original purpose of this was so that when fetching a web page, all the various components of the page (the images, javascript, stylesheets, etc) would be fetched over a single TCP connection, instead of a new connection being created for every HTTP request.

In the API, we leave the connection open for a small period of time so that high-scale applications can send many calls in a short period of time and reuse the TCP connection.

If you don't want this behavior, sending a HTTP header in your request of "Connection: close" will tell the server that you will not be making any further requests and it can close the TCP connection when it's done with the response.

For clarity, note that the keep-alive is configured at the web server, not the client (client here being Tropo). The client requests a keep-alive, the server determines exactly how that happens. For example, Apache's defaults are 15 seconds or 100 requests, whichever comes first. If you do a curl_close in your script, then curl explicitly closes the connection, otherwise, the remote server's in charge. 

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.