Problem: Recently found that Netty project every time the release of the Netty at the time of the restart will be occupied by the mouth of the exception, need to manually restart about more than 10 seconds, netty to restore the normal current speculation is due to Tomcat_restart when Netty perform related destruction operations, Channel.close (). awaituninterrupted () and Bossgroup and workergroup the socket was not completely closed when it was closed, perhaps in a time-wait state, causing the netty to be Occupancy resolution: Netty Bootstrap has an option SO_REUSEADDR that reuses socket addresses that are in time_wait but not completely shut down, because I did not find a port footprint if I restarted locally and dev with a large number of requests Can only be tested online when it is released, just the version posted on the line ... I forgot to open the so_reuseaddr ... So, only next time to see if there are effects Related: 1 TCP four wave TCP socket connection when the server unilaterally closed the connection, will enter the following four wave process (image from the network)
At this point, if the service socket is in the time-wait state, and the SO_REUSEADDR is not turned on, the port is occupied an exception 2) so_reuseaddr (excerpt from encyclopedia) This socket option notifies the kernel if the port is busy, but the TCP status is located in Time_wai T, you can reuse ports. If the port is busy and the TCP state is in another state, reusing the port still receives an error message indicating that "address is already in use". The SO_REUSEADDR option is useful when your service program stops and you want to reboot immediately, and the new socket still uses the same port. It is important to realize that any unexpected arrival of data at this time may result in confusion in the service program, but it is only possible, in fact, impossible