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 Peter Soles <pt...@gmail.com> on 2009/07/23 00:41:26 UTC
Using SSLClientIOEventDispatch
I checked the archives of the list - coudn't find the answer to my
question. Apologies if I missed something.
I'm writing a simulator that will simulate many clients long polling the
same server. The server requires SSL so I'm using HttpCore NIO with
SSLClientIOEventDispatch. When I test my code using SSL, my code appears to
submit the request 100 times and receives 100 responses, even though I have
only sent one event to the reactor. I pointed my code to two different
servers and got the same behavior.
I modified the code to use the DefaultClientIOEventDispatch and tried
connecting to servers that don't use SSL -- it works perfectly in this case.
I am obviously missing something here - any help would be appreciated!
Peter
Re: Using SSLClientIOEventDispatch
Posted by Peter Soles <pt...@gmail.com>.
Thanks Oleg - I guess I goofed in my understanding of how the handler works.
Need to read the tutorial (again!). I would definitely like to use a
connection manager to reuse the connection.
It's working great now! Thanks again for the help.
Peter
On Thu, Jul 23, 2009 at 5:17 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> Peter Soles wrote:
>
>> Thanks for the response. I am using 4.0.1 of HttpCore.
>>
>> I looked a little more into it and found that the number of requests and
>> responses is dependent on the server I am contacting. For example, I tried
>> pointing the code to the gmail login page and got many more than 100
>> request/response pairs.
>>
>> To run this code you just need a certificate for the client. In
>> Tester.java, just point the HttpClientNIO object to your certificate file,
>> SSL server, and port. For example, to contact gmail:
>>
>> HttpClientNIO httpClient = new HttpClientNIO(true,"my certificate", "
>> gmail.com <http://gmail.com>",443);
>> try {
>> httpClient.start();
>> } catch (IOReactorException e) {
>> e.printStackTrace();
>> }
>> // will just send a GET for now
>>
>> httpClient.sendRequest("/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%
>> 2Fmail.google.com <http://2Fmail.google.com>%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=zpwhtygjntrz&scc=1<mpl=default<mplcache=2",
>> new MyCallback());
>>
>> Peter
>>
>>
> Peter
>
> The problem is the RequestExecutionHandler#submitRequest method in your
> code. Every time this event is triggered, the request execution handler
> submits a new request. Effectively the handler keeps on sending requests to
> the server as long as the connection is kept alive. If you intend to execute
> one request only, the hander should submit one request only and then return
> null to indicate it has no more requests to submit. For details, please take
> a look at the following section of the HttpCore tutorial.
>
> http://hc.apache.org/httpcomponents-core/tutorial/html/nio.html#d0e2024
>
> If you want to re-use a persistent connection at a later point instead of
> opening a new connection, you should manage persistent connections using a
> connection manager of some sort:
>
>
> http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpClientConnManagement.java
>
> Hope that clarifies the problem somewhat.
>
> Oleg
>
>
>
> On Thu, Jul 23, 2009 at 7:36 AM, Oleg Kalnichevski <olegk@apache.org<mailto:
>> olegk@apache.org>> wrote:
>>
>> On Wed, Jul 22, 2009 at 06:41:26PM -0400, Peter Soles wrote:
>> > I checked the archives of the list - coudn't find the answer to my
>> > question. Apologies if I missed something.
>> >
>> > I'm writing a simulator that will simulate many clients long
>> polling the
>> > same server. The server requires SSL so I'm using HttpCore NIO with
>> > SSLClientIOEventDispatch. When I test my code using SSL, my code
>> appears to
>> > submit the request 100 times and receives 100 responses, even
>> though I have
>> > only sent one event to the reactor. I pointed my code to two
>> different
>> > servers and got the same behavior.
>> >
>> > I modified the code to use the DefaultClientIOEventDispatch and
>> tried
>> > connecting to servers that don't use SSL -- it works perfectly in
>> this case.
>> >
>> >
>> > I am obviously missing something here - any help would be
>> appreciated!
>> >
>> > Peter
>>
>> Peter,
>>
>> What version of HttpCore are you using? Please make sure you have
>> the latest
>> (4.0.1) release, as there has been a number of fixes related to the
>> non-blocking SSL support.
>>
>> Can you put together a test case and post it to this list?
>>
>> Oleg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> <ma...@hc.apache.org>
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> <ma...@hc.apache.org>
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Re: Using SSLClientIOEventDispatch
Posted by Oleg Kalnichevski <ol...@apache.org>.
Peter Soles wrote:
> Thanks for the response. I am using 4.0.1 of HttpCore.
>
> I looked a little more into it and found that the number of requests and
> responses is dependent on the server I am contacting. For example, I
> tried pointing the code to the gmail login page and got many more than
> 100 request/response pairs.
>
> To run this code you just need a certificate for the client. In
> Tester.java, just point the HttpClientNIO object to your certificate
> file, SSL server, and port. For example, to contact gmail:
>
> HttpClientNIO httpClient = new HttpClientNIO(true,"my certificate",
> "gmail.com <http://gmail.com>",443);
>
> try {
> httpClient.start();
> } catch (IOReactorException e) {
> e.printStackTrace();
> }
>
> // will just send a GET for now
>
> httpClient.sendRequest("/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%2Fmail.google.com
> <http://2Fmail.google.com>%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=zpwhtygjntrz&scc=1<mpl=default<mplcache=2",
> new MyCallback());
>
> Peter
>
Peter
The problem is the RequestExecutionHandler#submitRequest method in your
code. Every time this event is triggered, the request execution handler
submits a new request. Effectively the handler keeps on sending requests
to the server as long as the connection is kept alive. If you intend to
execute one request only, the hander should submit one request only and
then return null to indicate it has no more requests to submit. For
details, please take a look at the following section of the HttpCore
tutorial.
http://hc.apache.org/httpcomponents-core/tutorial/html/nio.html#d0e2024
If you want to re-use a persistent connection at a later point instead
of opening a new connection, you should manage persistent connections
using a connection manager of some sort:
http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpClientConnManagement.java
Hope that clarifies the problem somewhat.
Oleg
> On Thu, Jul 23, 2009 at 7:36 AM, Oleg Kalnichevski <olegk@apache.org
> <ma...@apache.org>> wrote:
>
> On Wed, Jul 22, 2009 at 06:41:26PM -0400, Peter Soles wrote:
> > I checked the archives of the list - coudn't find the answer to my
> > question. Apologies if I missed something.
> >
> > I'm writing a simulator that will simulate many clients long
> polling the
> > same server. The server requires SSL so I'm using HttpCore NIO with
> > SSLClientIOEventDispatch. When I test my code using SSL, my code
> appears to
> > submit the request 100 times and receives 100 responses, even
> though I have
> > only sent one event to the reactor. I pointed my code to two
> different
> > servers and got the same behavior.
> >
> > I modified the code to use the DefaultClientIOEventDispatch and tried
> > connecting to servers that don't use SSL -- it works perfectly in
> this case.
> >
> >
> > I am obviously missing something here - any help would be
> appreciated!
> >
> > Peter
>
> Peter,
>
> What version of HttpCore are you using? Please make sure you have
> the latest
> (4.0.1) release, as there has been a number of fixes related to the
> non-blocking SSL support.
>
> Can you put together a test case and post it to this list?
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> <ma...@hc.apache.org>
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> <ma...@hc.apache.org>
>
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Using SSLClientIOEventDispatch
Posted by Peter Soles <pt...@gmail.com>.
Thanks for the response. I am using 4.0.1 of HttpCore.
I looked a little more into it and found that the number of requests and
responses is dependent on the server I am contacting. For example, I tried
pointing the code to the gmail login page and got many more than 100
request/response pairs.
To run this code you just need a certificate for the client. In
Tester.java, just point the HttpClientNIO object to your certificate file,
SSL server, and port. For example, to contact gmail:
HttpClientNIO httpClient = new HttpClientNIO(true,"my certificate", "
gmail.com",443);
try {
httpClient.start();
} catch (IOReactorException e) {
e.printStackTrace();
}
// will just send a GET for now
httpClient.sendRequest("/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=http%3A%2F%
2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=zpwhtygjntrz&scc=1<mpl=default<mplcache=2",
new MyCallback());
Peter
On Thu, Jul 23, 2009 at 7:36 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Wed, Jul 22, 2009 at 06:41:26PM -0400, Peter Soles wrote:
> > I checked the archives of the list - coudn't find the answer to my
> > question. Apologies if I missed something.
> >
> > I'm writing a simulator that will simulate many clients long polling the
> > same server. The server requires SSL so I'm using HttpCore NIO with
> > SSLClientIOEventDispatch. When I test my code using SSL, my code appears
> to
> > submit the request 100 times and receives 100 responses, even though I
> have
> > only sent one event to the reactor. I pointed my code to two different
> > servers and got the same behavior.
> >
> > I modified the code to use the DefaultClientIOEventDispatch and tried
> > connecting to servers that don't use SSL -- it works perfectly in this
> case.
> >
> >
> > I am obviously missing something here - any help would be appreciated!
> >
> > Peter
>
> Peter,
>
> What version of HttpCore are you using? Please make sure you have the
> latest
> (4.0.1) release, as there has been a number of fixes related to the
> non-blocking SSL support.
>
> Can you put together a test case and post it to this list?
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Re: Using SSLClientIOEventDispatch
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, Jul 22, 2009 at 06:41:26PM -0400, Peter Soles wrote:
> I checked the archives of the list - coudn't find the answer to my
> question. Apologies if I missed something.
>
> I'm writing a simulator that will simulate many clients long polling the
> same server. The server requires SSL so I'm using HttpCore NIO with
> SSLClientIOEventDispatch. When I test my code using SSL, my code appears to
> submit the request 100 times and receives 100 responses, even though I have
> only sent one event to the reactor. I pointed my code to two different
> servers and got the same behavior.
>
> I modified the code to use the DefaultClientIOEventDispatch and tried
> connecting to servers that don't use SSL -- it works perfectly in this case.
>
>
> I am obviously missing something here - any help would be appreciated!
>
> Peter
Peter,
What version of HttpCore are you using? Please make sure you have the latest
(4.0.1) release, as there has been a number of fixes related to the
non-blocking SSL support.
Can you put together a test case and post it to this list?
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org