Binding Jetty HttpClient to Network Interface Card

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Binding Jetty HttpClient to Network Interface Card

davidjesse091
I will be using Jetty HttpClient on machines with two Network Interface Cards, I want the ability to force (bind) Jetty HttpClient to one of the NICs, would this be possible with Jetty HttpClient?
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding Jetty HttpClient to Network Interface Card

Lothar Kimmeringer
Hi,

Am 29.09.2016 um 22:08 schrieb [hidden email]:
> I will be using Jetty HttpClient on machines with two Network Interface Cards,
>  I want the ability to force (bind) Jetty HttpClient to one of the NICs, would
>  this be possible with Jetty HttpClient?

Doing a Google-search [1] brings up [2] as first result. Reading through
it I think the answer is yes.


Cheers, Lothar

[1] https://www.google.de/?gws_rd=ssl#q=jetty+http+client+binding
[2] http://download.eclipse.org/jetty/9.3.11.v20160721/apidocs/org/eclipse/jetty/client/HttpClient.html
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding Jetty HttpClient to Network Interface Card

davidjesse091
The setBindAddress method takes in an ipaddress or hostname and a port number, I don't understand what the port number is for. I used the binding functionality of Apache HttpComponents and I had to provide it with a InetAddress. But I am straggling to find a way to make it work for Jetty


-----Original Message-----
From: Lothar Kimmeringer <[hidden email]>
To: jetty-users <[hidden email]>
Sent: Thu, Sep 29, 2016 4:26 pm
Subject: Re: [jetty-users] Binding Jetty HttpClient to Network Interface Card

Hi,

Am 29.09.2016 um 22:08 schrieb [hidden email]:
> I will be using Jetty HttpClient on machines with two Network Interface Cards,
> I want the ability to force (bind) Jetty HttpClient to one of the NICs, would
> this be possible with Jetty HttpClient?

Doing a Google-search [1] brings up [2] as first result. Reading through
it I think the answer is yes.


Cheers, Lothar

[1] https://www.google.de/?gws_rd=ssl#q=jetty+http+client+binding
[2] http://download.eclipse.org/jetty/9.3.11.v20160721/apidocs/org/eclipse/jetty/client/HttpClient.html
_______________________________________________
jetty-users mailing list
jetty-[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding Jetty HttpClient to Network Interface Card

Lothar Kimmeringer
Hi,

Am 29.09.2016 um 22:36 schrieb [hidden email]:
> The setBindAddress method takes in an ipaddress or hostname and a port
>  number, I don't understand what the port number is for.

To specify where the client should listen for incoming requests.

>  I used the binding functionality of Apache HttpComponents and I
>  had to provide it with a InetAddress. But I am straggling to find
>  a way to make it work for Jetty

Find a free port and use it for calling that method, e.g.

ServerSocket ss = new ServerSocket(0, 1, getByName("192.168.1.1"));
SocketAddress sa = ss.getLocalSocketAddress();
ss.close();
jettyClient.setBindAddress(sa);

Since I don't use that kind of functionality (I'm developing on
the server side), this is just an educated guess.


Cheers, Lothar
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding Jetty HttpClient to Network Interface Card

davidjesse091
I tried putting 0 for the port and it's working now.


-----Original Message-----
From: Lothar Kimmeringer <[hidden email]>
To: jetty-users <[hidden email]>
Sent: Thu, Sep 29, 2016 4:48 pm
Subject: Re: [jetty-users] Binding Jetty HttpClient to Network Interface Card

Hi,

Am 29.09.2016 um 22:36 schrieb [hidden email]:
> The setBindAddress method takes in an ipaddress or hostname and a port
> number, I don't understand what the port number is for.

To specify where the client should listen for incoming requests.

> I used the binding functionality of Apache HttpComponents and I
> had to provide it with a InetAddress. But I am straggling to find
> a way to make it work for Jetty

Find a free port and use it for calling that method, e.g.

ServerSocket ss = new ServerSocket(0, 1, getByName("192.168.1.1"));
SocketAddress sa = ss.getLocalSocketAddress();
ss.close();
jettyClient.setBindAddress(sa);

Since I don't use that kind of functionality (I'm developing on
the server side), this is just an educated guess.


Cheers, Lothar
_______________________________________________
jetty-users mailing list
jetty-[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding Jetty HttpClient to Network Interface Card

Joakim Erdfelt-8
In reply to this post by Lothar Kimmeringer
Use .setBindAddress(SocketAddress)
Use the IP address of your NIC.
Set the port to the ephemeral port 0

Answered on stackoverflow too.

Joakim Erdfelt / [hidden email]

On Thu, Sep 29, 2016 at 1:47 PM, Lothar Kimmeringer <[hidden email]> wrote:
Hi,

Am 29.09.2016 um 22:36 schrieb [hidden email]:
The setBindAddress method takes in an ipaddress or hostname and a port
 number, I don't understand what the port number is for.

To specify where the client should listen for incoming requests.

 I used the binding functionality of Apache HttpComponents and I
 had to provide it with a InetAddress. But I am straggling to find
 a way to make it work for Jetty

Find a free port and use it for calling that method, e.g.

ServerSocket ss = new ServerSocket(0, 1, getByName("192.168.1.1"));
SocketAddress sa = ss.getLocalSocketAddress();
ss.close();
jettyClient.setBindAddress(sa);

Since I don't use that kind of functionality (I'm developing on
the server side), this is just an educated guess.


Cheers, Lothar

_______________________________________________
jetty-users mailing list
[hidden email]
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
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users