1

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?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Arya
  • 8,473
  • 27
  • 105
  • 175

1 Answers1

2

Use HttpClient.setBindAddress(java.net.SocketAddress) to set the address of the NIC you want to bind the output requests against.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136
  • Thanks for your answer, I tried it as httpClient.setBindAddress(new InetSocketAddress("192.168.1.129", 81)); It looks like it works, but if I run the program again it says "java.net.BindException: Address already in use: no further information" and I would have to give it another port number. – Arya Sep 29 '16 at 20:59
  • 1
    Use port 0, for outgoing connections you don't need to specify one. – Joakim Erdfelt Sep 29 '16 at 21:06
  • Can you also take a look at another question from me regarding Jetty? http://stackoverflow.com/questions/39781131/traffic-in-fiddler-from-jetty-httpclient-while-using-https – Arya Sep 30 '16 at 01:22