杀死Tomcat中的http nio连接的方法

我们有一个应用程序发送消息给用户通过与他们的设备的HTTPS连接访问我们的服务器(Apache Tomcat)。 问题是,这个用户应用程序正在Tomcat服务器中保持连接(或打开)。

为了解决这个问题,我们使用maxThreads="2700"connectionTimeout="20000"

 <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" maxThreads="2700" scheme="https" secure="true" keystoreFile="********" keystorePass="*****" clientAuth="false" sslProtocol="TLS" connectionTimeout="20000" ciphers="[lots of ciphers here]"/> 

事情是,我们的服务器进入繁忙的状态,我们甚至无法访问pipe理页面。 上次我们可以访问它,pipe理页面的http-nio-8443部分是:

 "http-nio-8443" Max threads: 2700 Current thread count: 1356 Current thread busy: 1354 Keeped alive sockets count: 1 Max processing time: 46426 ms Processing time: 6766.788 s Request count: 73225 Error count: 1415 Bytes received: 17.77 MB Bytes sent: 12.28 MB 

并在下面列出所有连接的客户端的连接细节。 他们在本节以“S”服务标记

因为我们的系统,我们知道这些连接不应该是活着的(我们知道我们可能在手机应用程序或我们的服务器有问题)

所以,我的问题是,没有杀死tomcat有没有办法在tomcat中杀死这些连接? 或者另一种方法也是好的。

从4.5开始,Linux内核支持SOCK_DESTROY操作,允许使用ss(8)来销毁套接字(包括连接到TCP / IP连接的套接字ss(8) 。 例如这里是一个SSH会话:

 $ set | grep SSH_CLIENT SSH_CLIENT='127.0.0.1 52266 22' $ 

看到与ss的连接:

 # ss dst 127.0.0.1:52266 Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port tcp ESTAB 0 0 127.0.0.1:ssh 127.0.0.1:52266 

终止连接:

 # ss --kill dst 127.0.0.1:52266 Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port tcp ESTAB 0 0 127.0.0.1:ssh 127.0.0.1:52266 

死亡人数:

 $ packet_write_wait: Connection to 127.0.0.1 port 22: Broken pipe $ 

有关SOCK_DESTROY信息的LWN文章