hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Multiple ports for Listening IO Reactor
Date Fri, 18 Jul 2014 19:25:06 GMT
On Fri, 2014-07-18 at 11:08 -0700, jax wrote:
> Hi All,
> I would like to have my listener handle requests on port 443 (ssl) and 8080
> and I'm not sure how to do that.
> I understand that I can do this:
> 
> // Listen of the given port
>    ioReactor.listen(new InetSocketAddress(443));
>    ioReactor.listen(new InetSocketAddress(8080));
> // Ready to go!
>    ioReactor.execute(ioEventDispatch);
> 
> However, the ioEventDispatch is tied to 
> 
> // Create server-side I/O event dispatch
>    IOEventDispatch ioEventDispatch = new
> DefaultHttpServerIODispatch(protocolHandler, connFactory);
> 
> and the connFactory is
> 
> NHttpConnectionFactory<DefaultNHttpServerConnection> connFactory;
> SSLContext sslcontext = SSLContext.getInstance("TLS");
> sslcontext.init(keymanagers, null, null);
> connFactory = new SSLNHttpServerConnectionFactory(sslcontext, null,
> ConnectionConfig.DEFAULT);
> 
> So how do I get the ioEventDispatch to handle incoming connections on 443
> and 8080?  I will have separate HttpAsyncRequestHandlers to deal with the
> request types - one handler for 443 and several different handlers for 8080.
> 
> Thanks in advance,
> 
> Jax.
> 

Jax,

There are two ways of going about the problem: (1) creating a custom
NHttpConnectionFactory that can optionally upgrade IOSession with
TLS/SSL support depending on the local port the session is bound to (2)
sub-classing AbstractIODispatch and making it select a different
connection factory based on the properties of the IOSession instance.

Hope this helps

Oleg



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


Mime
View raw message