Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] The resolve() function in SocketAddressResolver is called twice in https request in Jetty9.4.7

Hi,

 

I use Jetty 9.4.7 to write the https client to send the POST request. In my test, I found that sometime the log “customize socketAddressResolver, new host:port” printed twice, it is not always twice, sometime it is once. Could you please help investigate is there is any issue in Jetty 9.4.7?

My scenario:

 

The original POST request FQDN uri is a SRV FQDN. It has 2 targets, and each target has 2 IPs. only one IP is available for the request handling. So most time, the program will have the sending retry since only 1/4 IPs is good. Sometime, the twice calling on resolve() occurred in the good IP, sometime occurred in the bad IP.

 

            InetAddress ipAddr = …;

            client.setSocketAddressResolver(new SocketAddressResolver() {

 

                @Override

                public void resolve(String host, int port, Promise<List<InetSocketAddress>> promise) {

                    try {

                        InetSocketAddress ipSocketAddr = new InetSocketAddress(ipAddr, port);

                        List<InetSocketAddress> result = Collections.singletonList(ipSocketAddr);

 

                        if (mydebug.isDebugEnabled()) {

                            mydebug.debug("customize socketAddressResolver, new host:port " + ipAddr.getHostAddress()

+ ":" + port);

                        }

 

                        if (result.isEmpty())

                            promise.failed(new UnknownHostException());

                        else

                            promise.succeeded(result);

                      } catch (Throwable x) {

                          promise.failed(x);

                      }

              });

 

Regards,

William


Back to the top