2

We have an application that sends messages to users to access our server (Apache tomcat) through an HTTPS connection with their devices. Problem is that this users applications is keeping the connection alive (or open) in our Tomcat Server.

In an attempt to solve it we configured our connector with maxThreads="2700" and 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]"/>

The thing is that our server gets in a busy state that we can not even access the manager page. Last time we could access it the http-nio-8443 section of manager page was:

"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

And below that a list of all connected clients with the details of its connections. They are marked in this section with "S" of service

Because our system we know that these connections should not be alive anymore (we know that we may have a problem either in the phone app or in our server)

So, my question is, without killing the tomcat is there a way to kill those connections in tomcat? Or another method would also be good.

3
+50

Since 4.5 the Linux kernel supports the SOCK_DESTROY operation, allowing one to destroy sockets (including those connected to TCP/IP connections) e.g., with ss(8). For example here is an ssh session:

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

Seeing the connection with 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

Killing the connection:

# 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

Killed:

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

LWN article with info about SOCK_DESTROY

1
  • Since no other answer was given I will try to implement you solution in a systematic way. Thank you. And sorry for the long time to accept it. – Jorge Campos Jul 4 '16 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.