Questions tagged [time-wait]

The TIME_WAIT TCP port state

Indicates that both endpoints of a connection have closed it, and that the local end is keeping the local port in TIME_WAIT state. The system is waiting for any remaining packets to expire before closing the port. This state only lasts 2*MSL seconds where MSL is the maximum segment lifetime, typically 60 or 120 seconds.

The TIME_WAIT state is often erroneously regarded as a performance problem. It isn't, except for the length of netstat displays. However it can be avoided altogether by being the end which receives the first FIN. In practice this means the client should close the connection before the server, so that the ports in TIME_WAIT state accumulate at the client, where they are few, rather than at the server, where they are very many.

108 questions
84
votes
15 answers

Difference between webdriver.get() and webdriver.navigate()

What is the difference between get() and navigate() methods? Does any of this or maybe another method waits for page content to load? What do I really need is something like Selenium 1.0's WaitForPageToLoad but for using via webdriver. Any…
Invy
  • 1,058
  • 1
  • 10
  • 12
68
votes
6 answers

What is the cost of many TIME_WAIT on the server side?

Let's assume there is a client that makes a lot of short-living connections to a server. If the client closes the connection, there will be many ports in TIME_WAIT state on the client side. Since the client runs out of local ports, it becomes…
trustin
  • 12,231
  • 6
  • 42
  • 52
12
votes
1 answer

Go client program generates a lot a sockets in TIME_WAIT state

I have a Go program that generates a lot of HTTP requests from multiple goroutines. after running for a while, the program spits out an error: connect: cannot assign requested address. When checking with netstat, I get a high number (28229) of…
yigal
  • 3,923
  • 8
  • 37
  • 59
11
votes
1 answer

MySQL connection pool in python?

I'm trying to process large amount of data using Python and maintaining processing status in MySQL. However, I'm surprised there is no standard connection pool for python-mysql (like HikariCP in Java). I initially started with PyMySQL, things were…
8
votes
4 answers

What if the system time changes while I'm doing timed_wait with a duration?

When using timed_wait on a boost::condition_variable with a duration, will the wait condition time out after the duration even if the user (or ntp) changes the system time? E.g., boost::posix_time::time_duration wait_duration(0, 0, 1, 0); // 1…
indiv
  • 17,306
  • 6
  • 61
  • 82
5
votes
1 answer

ruby http connection pool

I have to create http connections within a rails app to pull some data from a remote server. I am using Net:HTTP, but the http connections created are not persistent. So I end up having lots of sockets in TIME_WAIT state, as these http connections…
Vasu
  • 2,406
  • 3
  • 20
  • 26
5
votes
1 answer

python SimpleHTTPRequestHandler server leaves socket in TIME_WAIT state after exit

I have a simple server written that extends the SimpleHTTPRequestHandler If I start and stop it without making any requests to the server, I can start back up on the same port with no problem. When started, a netstat looks like…
Hersheezy
  • 1,174
  • 1
  • 10
  • 17
5
votes
2 answers

Insufficient winsock resources

We have a c# web service and client, both created in Visual Studio 2008 (new project -> ASP.Net web service application). Service is hosted on Windows server 2012 R2, IIS 8.5. When the client sends the data to our service, we forward it to a 3rd…
dbrckovi
  • 121
  • 1
  • 1
  • 5
4
votes
3 answers

HttpClient with multiple proxies while handling socket exhaustion and DNS recycling

We are working on a fun project with a friend and we have to execute hundreds of HTTP requests, all using different proxies. Imagine that it is something like the following: for (int i = 0; i < 20; i++) { HttpClientHandler handler = new…
Hulkstance
  • 1,323
  • 9
  • 15
4
votes
3 answers

Port Stuck in Time_Wait

I have a TCP Tunnel in C#. I need to open and close the tunnel which is my app between a server and a client. I'm using this to close the data connection to test out another app. I have to use particular ports. On the second, third, nth…
4
votes
0 answers

Why TIME_WAIT state is needed by active close side, but not the passive close side?

Why TIME_WAIT state is needed by active close side, but not the passive close side? I think the network error will affect both side, why only the active close side need to wait? I think the passive side can also receive bad packet after the…
Myrfy
  • 575
  • 4
  • 11
4
votes
1 answer

Response.Flush in Classic ASP causing TIME_WAIT ports

I have recently become aware of this issue: https://blogs.msdn.microsoft.com/spike/2008/09/17/nested-recordset-and-the-portsocket-in-time_wait-problem-by-example/ Where if you open a recordset, then use the connection for something else with the…
4
votes
2 answers

Why does the RST packet not need the TIME_WAIT state?

I know that TIME_WAIT is to prevent delayed segments from one connection being misinterpreted as being part of a subsequent connection. Any segments that arrive whilst a connection is in the TIME_WAIT wait state are discarded. In my experiment, I…
Pengcheng
  • 439
  • 1
  • 4
  • 14
4
votes
1 answer

SO_REUSEADDR with UDP sockets on Linux. Is it necessary?

My UDP socket is bind()ing to port 53 (DNS). Does UDP have a TIME_WAIT state or is using SO_REUSEADDR pointless on UDP sockets?
dongle26
  • 826
  • 1
  • 10
  • 18
4
votes
2 answers

Java server socket doesn't reuse address

I am using a server socket in linux and I need to close it and reopen before the time_wait TCP status expires. I set the reuse address option of the server socket before the binding but it still throws a BindException. I also tried this…
Daniel
  • 279
  • 1
  • 5
  • 14
1
2 3 4 5 6 7 8