Skip to content

Commit f38d0a8

Browse files
committed
Fix hostname resolution for proxied connections
1 parent 3306c48 commit f38d0a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/io/nats/client/impl/SocketDataPort.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ public void connect(NatsConnection conn, NatsUri nuri, long timeoutNanos) throws
7474
socket.setTcpNoDelay(true);
7575
socket.setReceiveBufferSize(2 * 1024 * 1024);
7676
socket.setSendBufferSize(2 * 1024 * 1024);
77-
socket.connect(new InetSocketAddress(host, port), (int) timeout);
77+
InetSocketAddress inetSocketAddress = options.isNoResolveHostnames() ?
78+
InetSocketAddress.createUnresolved(host, port) : new InetSocketAddress(host, port);
79+
socket.connect(inetSocketAddress, (int) timeout);
7880

7981
if (isWebsocketScheme(nuri.getScheme())) {
8082
if (SECURE_WEBSOCKET_PROTOCOL.equalsIgnoreCase(nuri.getScheme())) {

0 commit comments

Comments
 (0)