diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java index 9be734bee6173..3838b271fcacb 100644 --- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java +++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java @@ -188,7 +188,9 @@ public ConnectionPool(InstrumentProvider instrumentProvider, private static AddressResolver createAddressResolver(ClientConfigurationData conf, EventLoopGroup eventLoopGroup) { DnsNameResolverBuilder dnsNameResolverBuilder = new DnsNameResolverBuilder() - .traceEnabled(true).channelType(EventLoopUtil.getDatagramChannelClass(eventLoopGroup)); + .traceEnabled(true) + .channelType(EventLoopUtil.getDatagramChannelClass(eventLoopGroup)) + .socketChannelType(EventLoopUtil.getSocketChannelClass(eventLoopGroup), true); if (conf.getDnsLookupBindAddress() != null) { InetSocketAddress addr = new InetSocketAddress(conf.getDnsLookupBindAddress(), conf.getDnsLookupBindPort()); diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/EventLoopUtil.java b/pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/EventLoopUtil.java index cfc766890f02d..57b7424ae6493 100644 --- a/pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/EventLoopUtil.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/common/util/netty/EventLoopUtil.java @@ -122,6 +122,16 @@ public static Class getServerSocketChannelClass(E } } + public static Class getSocketChannelClass(EventLoopGroup eventLoopGroup) { + if (eventLoopGroup instanceof IOUringEventLoopGroup) { + return IOUringSocketChannel.class; + } else if (eventLoopGroup instanceof EpollEventLoopGroup) { + return EpollSocketChannel.class; + } else { + return NioSocketChannel.class; + } + } + public static Class getDatagramChannelClass(EventLoopGroup eventLoopGroup) { if (eventLoopGroup instanceof IOUringEventLoopGroup) { return IOUringDatagramChannel.class; diff --git a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java index 4ee15fd7124a6..beb9e39f6fb5c 100644 --- a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java +++ b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java @@ -179,7 +179,8 @@ public ProxyService(ProxyConfiguration proxyConfig, this.authenticationService = authenticationService; DnsNameResolverBuilder dnsNameResolverBuilder = new DnsNameResolverBuilder() - .channelType(EventLoopUtil.getDatagramChannelClass(workerGroup)); + .channelType(EventLoopUtil.getDatagramChannelClass(workerGroup)) + .socketChannelType(EventLoopUtil.getSocketChannelClass(workerGroup), true); DnsResolverUtil.applyJdkDnsCacheSettings(dnsNameResolverBuilder); dnsAddressResolverGroup = new DnsAddressResolverGroup(dnsNameResolverBuilder);