pushy icon indicating copy to clipboard operation
pushy copied to clipboard

lots of udp ports opening

Open cyflhn opened this issue 3 years ago • 7 comments

We have several apps which needs to send notifications to apns through pushy. We found that there are lots of udp ports opening on our servers. I checked the source code and found that all these ports are related to dns resolver in netty. For all ApnsClient objects, they share the same NioEventLoopGroup instance. But in AddressResolverGroup of netty, it creates an instance of InetSocketAddressResolver for each NioEventLoop . I think it is the cause of so many opening udp ports. I don't think it is necessary to create so many InetSocketAddressResolver instances. Do you have ideas to optimize this issue?

cyflhn avatar Apr 19 '21 04:04 cyflhn

@jchambers any solution on this issue?

cyflhn avatar Apr 23 '21 09:04 cyflhn

Hi @cyflhn

I have the same issue, and finally I found that may be some netty packages were downgraded to lower versions caused by other dependencies.

In my case, io.netty:netty-resolver-dns is downgraded to 4.1.29.Final, that caused too many udp ports opening, After I forced set the io.netty:netty-resolver-dns to a higher version, the issue resolved.

+--- com.eatthepath:pushy:0.14.2
|    |    +--- io.netty:netty-codec-http2:4.1.53.Final -> 4.1.29.Final
|    |    |    +--- io.netty:netty-codec-http:4.1.29.Final
|    |    |    |    \--- io.netty:netty-codec:4.1.29.Final (*)
|    |    |    \--- io.netty:netty-handler:4.1.29.Final (*)
|    |    +--- io.netty:netty-handler-proxy:4.1.53.Final -> 4.1.29.Final
|    |    |    +--- io.netty:netty-transport:4.1.29.Final -> 4.1.62.Final (*)
|    |    |    +--- io.netty:netty-codec-socks:4.1.29.Final
|    |    |    |    \--- io.netty:netty-codec:4.1.29.Final (*)
|    |    |    \--- io.netty:netty-codec-http:4.1.29.Final (*)
|    |    +--- io.netty:netty-resolver-dns:4.1.53.Final -> 4.1.29.Final (*)
|    |    +--- com.eatthepath:fast-uuid:0.1
|    |    \--- org.slf4j:slf4j-api:1.7.21 -> 1.7.25

jianggaocheng avatar May 04 '21 02:05 jianggaocheng

hi, @jianggaocheng I have upgraded io.netty:netty-resolver-dns to 4.1.53.Final, but the problem still exists.

cyflhn avatar May 06 '21 03:05 cyflhn

@cyflhn Maybe other netty dependency is still low version?

jianggaocheng avatar May 08 '21 13:05 jianggaocheng

@jianggaocheng I am sure there is no other netty dependencies in our module. You can look into the source code of getResolver method in AddressResolverGroup. If all apns clients share a common nioeventgroup, it is possible that there are lots of instances of dns AddressResolver which are created by getResolver method .

cyflhn avatar May 09 '21 02:05 cyflhn

Folks, is this causing a practical problem? In the absence of actually harmful side effects, my thought is that the best way to address this is to get #540 done.

jchambers avatar May 10 '21 13:05 jchambers

@jchambers the number of opening udp ports is limited on a server, we need udp ports to resolve other domains. On the other hand, it is not necessary to open so many udp ports to resolve the same domain. it is a kind of big waste of udp resources.

cyflhn avatar May 11 '21 01:05 cyflhn