Open luccotta opened 2 years ago
I found out that this is happening when the exception bellow happens. Every time it does, around 50 file descriptors are opened and never closed. I tried to test this solution which makes a lot of sense, but apparently it did not solve the issue.
2022-07-27 10:36:53 ERROR SendPushNotification:
java.util.concurrent.ExecutionException: java.net.ConnectException: Connection timed out
at org.apache.http.concurrent.BasicFuture.getResult(BasicFuture.java:71)
at org.apache.http.concurrent.BasicFuture.get(BasicFuture.java:84)
at org.apache.http.impl.nio.client.FutureWrapper.get(FutureWrapper.java:70)
at nl.martijndwars.webpush.PushService.send(PushService.java:64)
at nl.martijndwars.webpush.PushService.send(PushService.java:68)
at ....
Caused by: java.net.ConnectException: Connection timed out
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:174)
at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:148)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351)
at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221)
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64)
... 1 more
Hello, I scheduled this service to be executed every 15 min in a new thread, to send 1 to 10 notifications on average. For each notification, I create a new
PushService
and callpushService.send(notification)
. Is that ok? Should I be doing something differently like reusing the same PushService?The threads are not getting terminated, eventually my server exceeds the maximum allowed open files in Linux, and I start getting
SocketException: Too many open files
everywhere. All threads get stuck with the following stack trace:I know this is from
webpush-java
because it's the only lib in my project usinghttpcore-nio
. Also I used this tool to investigate what was opening so many files and could see this stack fromwebpush-java
:Thanks