Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Client tries to connect to ipv6 host when bound to ipv4 interface


On Wed, Dec 21, 2022 at 8:33 AM Matthias Pfau via jetty-users
<jetty-users@xxxxxxxxxxx> wrote:
> Hi there,
> with jetty 11, we bind the http client to an ipv4 address as follows:
> httpClient.setBindAddress(new InetSocketAddress(serverConfig.getIpv4Address(), 0));
> We lately noticed, that this client can't connect to certain websites:
> java.util.concurrent.ExecutionException: Could not connect to[2001:67c:26b4:2:21e:bff:fec7:87a]:443 <[2001:67c:26b4:2:21e:bff:fec7:87a]:443>      at org.eclipse.jetty.client.util.FutureResponseListener.getResult(      at org.eclipse.jetty.client.util.FutureResponseListener.get(     at org.eclipse.jetty.client.HttpRequest.send(      at org.eclipse.jetty.client.HttpClient.GET( at org.eclipse.jetty.client.HttpClient.GET(
> It seems like the client that was bound to the ipv4 address tries to connect to the ipv6 address of <> which is impossible.
> Did we miss something or is this a bug?


"f a socket is bound to an IPv6 anylocal address on a dual-stack
machine, it can accept both IPv6 and IPv4 traffic; if it is bound to
an IPv4 (IPv4-mapped) anylocal address, it can only accept IPv4

Seems that the scenario you have is not supported by the JDK.

Simone Bordet
Developer advice, training, services and support
from the Jetty & CometD experts.

Back to the top