关闭 netty 连接会在 TIMED_WAIT 中留下连接

Closing netty connection leaves the connection in TIMED_WAIT

我有以下代码来启动 netty 服务器:

    Application application = ApplicationTypeFactory.getApplication(type);
    resteasyDeployment = new ResteasyDeployment();

    // Explicitly setting the Application should prevent scanning
    resteasyDeployment.setApplication(application);

    // Need to set the provider factory to the default, otherwise the
    // providers we need won't be registered, such as JSON mapping
    resteasyDeployment.setProviderFactory(ResteasyProviderFactory.getInstance());

    netty = new NettyJaxrsServer();

    netty.setHostname(HOST);
    netty.setPort(port);        
    netty.setDeployment(resteasyDeployment);        

    // Some optional extra configuration
    netty.setKeepAlive(true);
    netty.setRootResourcePath("/");
    netty.setSecurityDomain(null);
    netty.setIoWorkerCount(16);
    netty.setExecutorThreadCount(16);

    LOGGER.info("Starting REST server on: " + System.getenv("HOSTNAME") + ", port:" + port);        
    // Start the server
    //("Starting REST server on " + System.getenv("HOSTNAME"));
    netty.start();

    LOGGER.info("Started!");  

当我这样做时:

   netty.stop()

好像没有关闭连接:

[john@dub-001948-VM01:~/workspace/utf/atf/src/test/resources ]$ netstat    -anp | grep 8888
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 ::ffff:10.0.21.88:8888      ::ffff:10.0.21.88:60654     TIME_WAIT   -                   
tcp        0      0 ::ffff:10.0.21.88:8888      ::ffff:10.0.21.88:60630     TIME_WAIT   -                    
tcp        0      0 ::ffff:10.0.21.88:8888      ::ffff:10.0.21.88:60629     TIME_WAIT   -                   
tcp        0      0 ::ffff:10.0.21.88:8888      ::ffff:10.0.21.88:60637     TIME_WAIT   -                   
tcp        0      0 ::ffff:10.0.21.88:8888      ::ffff:10.0.21.88:60640     TIME_WAIT   -  

即使在程序退出后。在其他帖子中,我读到 netty 不会在停止时关闭客户端连接。如何彻底关闭它?

Time_Wait 是套接字状态之一。应用程序对此无能为力。此处有更多信息:http://www.isi.edu/touch/pubs/infocomm99/infocomm99-web/。对于繁忙的服务器,您可以调整一些 tcp/ip 参数以减轻其影响。