You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Eugen Kondrashev <ek...@rambler.ru> on 2012/12/12 17:27:25 UTC

Multiple http clients at one runtime

Hi experts,

I'm using commons-httpclient-3.1 for my project purposes.

There are infrastructure and client layers in the project.
Infrastructure uses http client to talk to the server(over ssl), while client layer performing requests to third party sites(both http\https).

And the requirement is that the http client that is communicating to server should determine its own Protocol instance for "https" scheme(with its own socket factory), while the one from the client layer needs to introduce another Protocol instance for the _same_ "https" scheme(with socket factory configured to auto-accept remote certificates for example).

So, current problem is that it can exist only one Protocol instance for the same scheme type. And now I'm facing with issue when infra layer stops communicating with server once the client layer has established https connection to some third party site.

The exception I keep getting is 
java.net.SocketException: Already bound
at java.net.Socket.bind(Socket.java:614)
at sun.security.ssl.BaseSSLSocketImpl.bind(BaseSSLSocketImpl.java:114)
at sun.security.ssl.SSLSocketImpl.bind(SSLSocketImpl.java:65)

And the funny thing that this exception comes from socket factory defined from the client layer, while the call is done from the infra layer.

So my questions are:
1) Is possibility to cover described scenario with httpclient of 3.1 version? Perhaps it is possible to specify Protocol explicitly for the client so it will be used while executing requests? I do know about HostConfiguration class, but from the source code I see that protocol scheme is taken from the URI itself if it is of absolute type, so the passed hostConfiguration is changed internally.


2)I still doubting that described issue is the root cause of the "Already bound" SocketException. Does anybody have any other version of what is happening?

Thanks,
Eugene







Eugen Kondrashev.
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Multiple http clients at one runtime

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2012-12-12 at 20:27 +0400, Eugen Kondrashev wrote:
> Hi experts,
> 
> I'm using commons-httpclient-3.1 for my project purposes.
> 
> There are infrastructure and client layers in the project.
> Infrastructure uses http client to talk to the server(over ssl), while client layer performing requests to third party sites(both http\https).
> 
> And the requirement is that the http client that is communicating to server should determine its own Protocol instance for "https" scheme(with its own socket factory), while the one from the client layer needs to introduce another Protocol instance for the _same_ "https" scheme(with socket factory configured to auto-accept remote certificates for example).
> 
> So, current problem is that it can exist only one Protocol instance for the same scheme type. And now I'm facing with issue when infra layer stops communicating with server once the client layer has established https connection to some third party site.
> 
> The exception I keep getting is 
> java.net.SocketException: Already bound
> at java.net.Socket.bind(Socket.java:614)
> at sun.security.ssl.BaseSSLSocketImpl.bind(BaseSSLSocketImpl.java:114)
> at sun.security.ssl.SSLSocketImpl.bind(SSLSocketImpl.java:65)
> 
> And the funny thing that this exception comes from socket factory defined from the client layer, while the call is done from the infra layer.
> 
> So my questions are:
> 1) Is possibility to cover described scenario with httpclient of 3.1 version? Perhaps it is possible to specify Protocol explicitly for the client so it will be used while executing requests? I do know about HostConfiguration class, but from the source code I see that protocol scheme is taken from the URI itself if it is of absolute type, so the passed hostConfiguration is changed internally.
> 
> 
> 2)I still doubting that described issue is the root cause of the "Already bound" SocketException. Does anybody have any other version of what is happening?
> 
> Thanks,
> Eugene
> 
> 

Eugene

I am very sorry but HC 3.x is no longer supported. Please consider
upgrading to HC 4.x

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org