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 Gajo Csaba <cs...@cosylab.com> on 2010/03/18 11:58:42 UTC

How to fail immediately on broken connection?

Hello,

I was suing the asynchronous client example from [1] to write a simple 
client. The problem is, when the server is not online, the connection 
just halts and waits, due to the CountDownLatch. I thought that the 
SessionRequestCallback object was supposed to deal with this? However, 
when I try to connect, the completed() method immediately returns 
success is true, and I'm left hanging. The failed() method is never 
invoked. Why is that?

Basically, what I want to do is, if the server is not available, to just 
print out some message. How to do that?

Thanks, Csaba

[1] - 
http://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpClient.java


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


Re: How to fail immediately on broken connection?

Posted by Gajo Csaba <cs...@cosylab.com>.
OK now for some reason the SessionRequestCallback object is working, and 
I was able to fix the problem.

Csaba


On 03/18/2010 11:58 AM, Gajo Csaba wrote:
> Hello,
>
> I was suing the asynchronous client example from [1] to write a simple 
> client. The problem is, when the server is not online, the connection 
> just halts and waits, due to the CountDownLatch. I thought that the 
> SessionRequestCallback object was supposed to deal with this? However, 
> when I try to connect, the completed() method immediately returns 
> success is true, and I'm left hanging. The failed() method is never 
> invoked. Why is that?
>
> Basically, what I want to do is, if the server is not available, to 
> just print out some message. How to do that?
>
> Thanks, Csaba
>
> [1] - 
> http://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.0.x/httpcore-nio/src/examples/org/apache/http/examples/nio/NHttpClient.java 
>
>
>
> ---------------------------------------------------------------------
> 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