A feature of HTTP where the same connection is used for multiple requests, speeding up downloading of web pages with multiple resources.
Questions tagged [keep-alive]
892 questions
115
votes
8 answers
Does a TCP socket connection have a "keep alive"?
I have heard of HTTP keep-alive but for now I want to open a socket connection with a remote server.
Now will this socket connection remain open forever or is there a timeout limit associated with it similar to HTTP keep-alive?

Kevin Boyd
- 12,121
- 28
- 86
- 128
109
votes
5 answers
WebSockets ping/pong, why not TCP keepalive?
WebSockets have the option of sending pings to the other end, where the other end is supposed to respond with a pong.
Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in
response, unless it already received a Close frame. It…

Thomas
- 174,939
- 50
- 355
- 478
107
votes
1 answer
Keep-alive header clarification
I was asked to build a site , and one of the co-developer told me That I would need to include the keep-alive header.
Well I read alot about it and still I have questions.
msdn ->
The open connection improves performance when a client makes…

Royi Namir
- 144,742
- 138
- 468
- 792
98
votes
4 answers
http keep-alive in the modern age
So according to the haproxy author, who knows a thing or two about http:
Keep-alive was invented to reduce CPU
usage on servers when CPUs were 100
times slower. But what is not said is
that persistent connections consume a
lot of memory…

Michael Neale
- 19,248
- 19
- 77
- 109
70
votes
3 answers
How does Keep-alive work with ThreadPoolExecutor?
In continuation to a question posted by me, I'm trying to use ThreadPoolExecutor in my codebase. Even after repeated attempts to comprehend from Java API doc, I failed to understand clearly the functionality/purpose behind keepAliveTime parameter…

Gnanam
- 10,613
- 19
- 54
- 72
69
votes
11 answers
How do I shutdown a Node.js http(s) server immediately?
I have a Node.js application that contains an http(s) server.
In a specific case, I need to shutdown this server programmatically. What I am currently doing is calling its close() function, but this does not help, as it waits for any kept alive…

Golo Roden
- 140,679
- 96
- 298
- 425
65
votes
4 answers
Persistent/keepalive HTTP with the PHP Curl library?
I'm using a simple PHP library to add documents to a SOLR index, via HTTP.
There are 3 servers involved, currently:
The PHP box running the indexing job
A database box holding the data being indexed
The solr box.
At 80 documents/sec (out of 1…

Frank Farmer
- 38,246
- 12
- 71
- 89
49
votes
2 answers
python requests module and connection reuse
I am working with python's requests module for HTTP communication, and I am wondering how to reuse already-established TCP connections? The requests module is stateless and if I repeatedly call get for the same URL, wouldn't it create a new…

gmemon
- 2,573
- 5
- 32
- 37
48
votes
2 answers
HTTP keep-alive timeout
Can I specify the HTTP timeout or does the server impose a value?
For example, if I do:
telnet my.server.net 80
Trying X.X.X.X...
Connected to my.server.net.
Escape character is '^]'.
GET /homepage.html HTTP/1.0
Connection: keep-alive
Host:…

Ricky Robinson
- 21,798
- 42
- 129
- 185
48
votes
3 answers
How to set the HTTP Keep-Alive timeout in a nodejs server
I'm actually doing some load testing against an ExpressJS server, and I noticed that the response send by the server includes a "Connection: Keep-Alive" header. As far as I understand it, the connection will remain opened until the server or the…

Miguel L.
- 708
- 2
- 7
- 11
42
votes
7 answers
Python urllib2 with keep alive
How can I make a "keep alive" HTTP request using Python's urllib2?

ibz
- 44,461
- 24
- 70
- 86
38
votes
6 answers
How to keep an iPhone app running on background fully operational
first of all, I know there is only support for voip, audio and location apps to run in background and that they will run just while the audio is been played or while using location services, etc.
What I want to know is if there is a way to keep my…

Paul N
- 1,901
- 1
- 22
- 32
38
votes
3 answers
How to change tcp keepalive timer using python script?
In my python script, I have activate TCP Keepalive using this command:
x = s.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
My goal is for socket connection to get closed, if there is no transmission(*) for 5 minutes. I am working on…

John
- 381
- 1
- 3
- 4
36
votes
2 answers
Difference in docker restart policy between on-failure and unless-stopped?
I have read the docker-compose documentation about restart policy of containers,
However I failed to understand the difference between on-failure and unless-stopped.
When will I use one over the other? In which situations a certain policy will lead…

moshevi
- 4,999
- 5
- 33
- 50
33
votes
8 answers
HttpsUrlConnection and keep-alive
I am using com.sun.net.httpserver.HttpsServer in my current project which deals with client-authentification etc.. Currently it only prints out the clients address/port, so that I can check if one TCP-connection is used for multiple requests…

Biggie
- 7,037
- 10
- 33
- 42