Hi Simone,

I tried to use directly the low-level HTTP2Client, it works well. Many thanks 
for the quick response and great help.

Best Regards,
William

-----Original Message-----
From: [email protected] [mailto:[email protected]] 
On Behalf Of Simone Bordet
Sent: 2017年11月1日 18:04
To: JETTY user mailing list <[email protected]>
Subject: Re: [jetty-users] How to set the local IP address when using 
Http2Client to send http2 request out

Hi,

On Wed, Nov 1, 2017 at 3:23 AM, Cao, William (NSB - CN/Qingdao) 
<[email protected]> wrote:
> Hi,
>
> I am trying to use Jetty 9.4.7 + JDK1.8.0_141 as the HTTP2 client. I 
> used the sample code in below link.  In my client host, there are 
> multiple IP addresses. Since there is no local IP address specified in 
> the code, the client will use one as the local ip address to send the http2 
> request out.
> However, I need to set the local IP address but not to use the default one.
> How to set the local IP address before sending out the request?

This functionality is available if you use Jetty's HttpClient with the
HTTP/2 transport, see
http://www.eclipse.org/jetty/documentation/current/http-client-transport.html#_http_2_transport.

With that setup, you can do:

HTTP2Client h2Client = new HTTP2Client();
HttpClientTransportOverHTTP2 transport = new 
HttpClientTransportOverHTTP2(h2Client);
HttpClient client = new HttpClient(transport, null); 
client.setBindAddress(<your local address here>); client.start();

If you want to use directly the low-level HTTP2Client, you can do it in this 
way:

HTTP2Client h2Client = new HTTP2Client() {
    @Override
    protected void configure(SocketChannel channel) throws IOException {
        super.configure(channel);
        channel.bind(<your local address here>);
    }
};

Cheers

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support from the Jetty & CometD 
experts.
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to