Skip to content

Commit

Permalink
Fix issue #561 in ZitiConnectionSocketFactory (#562)
Browse files Browse the repository at this point in the history
* Fixed #557 with the response timeout using the incorrect units
Added convenience constructor to ZitiConnectionSocketFactory for referencing an existing ZitiContext

* Fix #561 by using the InetSocketAddress.createUnresolved to avoid the host lookup delay
  • Loading branch information
ahazeltonNF authored Mar 13, 2024
1 parent c132d76 commit 1c072f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public Socket createSocket(HttpContext context) throws IOException {
public Socket connectSocket(TimeValue timeValue, Socket socket, HttpHost host, InetSocketAddress inetSocketAddress, InetSocketAddress localAddress, HttpContext context) throws IOException {

final Socket sock = socket != null ? socket : createSocket(context);
sock.connect(new InetSocketAddress(host.getHostName(), host.getPort()), timeValue.toMillisecondsIntBound());
// can leave InetSocketAddress as unresolved since ziti performs a service lookup using the host and port
sock.connect(InetSocketAddress.createUnresolved(host.getHostName(), host.getPort()), timeValue.toMillisecondsIntBound());
if (localAddress != null) {
sock.bind(localAddress);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public Socket connectSocket(TimeValue timeValue, Socket socket, HttpHost host, I
}
}

final InetSocketAddress address = new InetSocketAddress(host.getHostName(), host.getPort());
// can leave as unresolved since ziti performs a service lookup using the address and port
final InetSocketAddress address = InetSocketAddress.createUnresolved(host.getHostName(), host.getPort());
final Socket sock = sslSocketFactory.createSocket(address.getAddress(), address.getPort());
if (localAddress != null) {
sock.bind(localAddress);
Expand Down

0 comments on commit 1c072f4

Please sign in to comment.