Netty Port is occupied problem

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.