The error actually does not come from MySQL, but from Windows itself:
When a connection is closed, on the side that is closing the connection, the tuple {Protocol, Local IP, Local Port, Remote IP, Remote Port} enters a TIME_WAIT state for 240 seconds by default.
In this case, the protocol is corrected - TCP
Local IP, Remote IP, and Remote PORT are also typically fixed. Therefore, the variable is the local port.
What happens is that when you do not bind a port in the range 1024-5000 is used. So, roughly, you have 4000 ports. If you use all of them in 4 minutes - meaning that you make 16 web service calls per second for 4 minutes, you will exhaust all ports. That is the cause of this exception.
In other words, you ran out of doors in the dynamic range. This probably should not be happening.
how to fix:
To set TcpTimedWaitDelay (TIME_WAIT): Use the regedit command to access the HKEY_LOCAL_MACHINESYSTEMCurrentControlSet ServicesTCPIPParameters registry subkey. Create a new REG_DWORD value named TcpTimedWaitDelay. ... Stop and restart the system.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…