You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by bea <st...@yahoo.com> on 2007/10/24 22:18:50 UTC

How to timeout connection attempt?

Say I have some code as follows:

ConnectFuture future = connector.connect(address, handler);
future.join(TIMEOUT);

If the connection has not been made when the timeout expires, does mina
continue to keep trying to make the connection? 

The behavior I am looking for is that when the timeout expires, the current
connection attempt is abandoned. How can I achieve this? Should I use the
SocketConnectorConfig.setConnectTimeout() method and set the timeout to the
same value as the join() method?

What is the workertimeout for?

Thanks for your help.
-- 
View this message in context: http://www.nabble.com/How-to-timeout-connection-attempt--tf4686788s16868.html#a13394156
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: How to timeout connection attempt?

Posted by mat <fo...@gmail.com>.
I believe join is only to block the function call for certain time.
setconnectTimeout means socket will keep trying until timeout. The only way
to find out connection failure is catch the RuntimeIOException.


On 10/25/07, bea <st...@yahoo.com> wrote:
>
>
> Say I have some code as follows:
>
> ConnectFuture future = connector.connect(address, handler);
> future.join(TIMEOUT);
>
> If the connection has not been made when the timeout expires, does mina
> continue to keep trying to make the connection?
>
> The behavior I am looking for is that when the timeout expires, the
> current
> connection attempt is abandoned. How can I achieve this? Should I use the
> SocketConnectorConfig.setConnectTimeout() method and set the timeout to
> the
> same value as the join() method?
>
> What is the workertimeout for?
>
> Thanks for your help.
> --
> View this message in context:
> http://www.nabble.com/How-to-timeout-connection-attempt--tf4686788s16868.html#a13394156
> Sent from the Apache MINA Support Forum mailing list archive at Nabble.com
> .
>
>

Re: How to timeout connection attempt?

Posted by Trustin Lee <tr...@gmail.com>.
On 10/25/07, bea <st...@yahoo.com> wrote:
>
> Say I have some code as follows:
>
> ConnectFuture future = connector.connect(address, handler);
> future.join(TIMEOUT);
>
> If the connection has not been made when the timeout expires, does mina
> continue to keep trying to make the connection?
>
> The behavior I am looking for is that when the timeout expires, the current
> connection attempt is abandoned. How can I achieve this? Should I use the
> SocketConnectorConfig.setConnectTimeout() method and set the timeout to the
> same value as the join() method?

The connection attempt is automatically canceled after 1 minute by
default.  To change the timeout value, you have to call
SocketConnectorConfig.setConnectTimeout(), as you already noticed.

Unfortunately, there's no way to cancel the connection attempt
immediately.  Good news is that you will be able to do that in 2.0; we
already implemented that.

> What is the workertimeout for?

It's timeout for the I/O connector worker threads.  Please search forum.

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