You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by HansJ <la...@mail.dk> on 2007/09/11 16:15:13 UTC

tcp client - how to detect connect problems

Hello

Using the MINA NetCat as the example.
I'm using MINA 1.1.2.

I'm struggling to understand how MINA tcp clients detects connects errors,
i.e. when an initial tcp connection cannot be made.

I would like to separate into different scenarios:

1. Endpoint specified by hostname, port#. Problem:  hostname cannot be
resolved.

I know the answer myself to this one: It will result in an OS error that
will be thrown as an exception.

2. Endpoint specified by ip, port#. Problem:  ip address does not exist on
network.


3. Endpoint specified by hostname or ip, port#. Problem: host reachable, but
no listener on that port.

I've tested this scenario. Nothing happens, no callback, nothing, the NetCat
application just ends after approximately 1 minute. ConnectTimeout is set to
15 secs.


4. Endpoint specified by hostname or ip, port#. Problem: host unreachable.




In another posting I've read that the ConnectTimeout only has relevance when
there is a listener on the host/port destination. Can't really understand
what it is good for then. 

Someone able to help me understand this. 

thanks

-- 
View this message in context: http://www.nabble.com/tcp-client---how-to-detect-connect-problems-tf4422882s16868.html#a12615648
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: tcp client - how to detect connect problems

Posted by Trustin Lee <tr...@gmail.com>.
On 9/13/07, Trustin Lee <tr...@gmail.com> wrote:
> On 9/11/07, HansJ <la...@mail.dk> wrote:
<snip/>

> > 3. Endpoint specified by hostname or ip, port#. Problem: host reachable, but
> > no listener on that port.
> >
> > I've tested this scenario. Nothing happens, no callback, nothing, the NetCat
> > application just ends after approximately 1 minute. ConnectTimeout is set to
> > 15 secs.
>
> It's just because IoHandler is not invoked at all when the connection
> attempt fails.  IoConnector.connect() returns a ConnectFuture, so you
> can add an handler to it, or wait for the future by calling join() and
> call getSession() to get the connected session.

http://tinyurl.com/2rlsks

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: tcp client - how to detect connect problems

Posted by Trustin Lee <tr...@gmail.com>.
On 9/11/07, HansJ <la...@mail.dk> wrote:
>
> Hello
>
> Using the MINA NetCat as the example.
> I'm using MINA 1.1.2.
>
> I'm struggling to understand how MINA tcp clients detects connects errors,
> i.e. when an initial tcp connection cannot be made.
>
> I would like to separate into different scenarios:
>
> 1. Endpoint specified by hostname, port#. Problem:  hostname cannot be
> resolved.
>
> I know the answer myself to this one: It will result in an OS error that
> will be thrown as an exception.
>
> 2. Endpoint specified by ip, port#. Problem:  ip address does not exist on
> network.
>

I confirmed these two cases for fine.

> 3. Endpoint specified by hostname or ip, port#. Problem: host reachable, but
> no listener on that port.
>
> I've tested this scenario. Nothing happens, no callback, nothing, the NetCat
> application just ends after approximately 1 minute. ConnectTimeout is set to
> 15 secs.

It's just because IoHandler is not invoked at all when the connection
attempt fails.  IoConnector.connect() returns a ConnectFuture, so you
can add an handler to it, or wait for the future by calling join() and
call getSession() to get the connected session.

To be more concise, timeout is processed correctly in MINA.

> 4. Endpoint specified by hostname or ip, port#. Problem: host unreachable.

This case should work fine.  Please let us know if it doesn't work well.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6