You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by chihiro <ga...@gmail.com> on 2007/10/17 12:29:28 UTC
weird behaviour using ConnectFuture
I have a connect() method that looks like this:
private void connect()
{
try
{
ConnectFuture future = m_connector.connect( new
InetSocketAddress( m_address, m_port ), m_handler, m_config );
boolean operationFinished = future.join( CONNECT_FUTURE_TIMEOUT
);
if( !operationFinished )
throw new RuntimeIOException( "timeout waiting for connect
to complete" );
future.getSession();
debug( "after future.getSession" );
m_connectFuture = future;
} catch( RuntimeIOException e )
{
long count = 0L;
if( (count = m_logCounter.getAndIncrement()) % 5000 == 0 )
debug( " (" + count + ") failed to connect to " + m_address
+ ":" + m_port );
}
}
My test scenario:
Start the server listening on a port number p.
Start the client (which connects to p)
Before the client sends data to the server, stop the server. (do a
netstat -t to verify that the port is gone)
When the client detects that it is not connected; it will attempt to call
connect() repeatedly
until it succeeds. We'd expect future.getSession() to fail (correct me if
I'm wrong).
And for a while, this holds true. But after about 30-40 seconds, the call
future.getSession() magically
succeeds. And ConnectFuture.isConnected() returns true!
IoSession.isConnected() is also true.
The client would write a newline delimited line of text & the handler's
messageReceived() receives the message.
It's like I'm connected to an echo service.
Has anyone experienced this before ?
Thanks,
chihiro
--
View this message in context: http://www.nabble.com/weird-behaviour-using-ConnectFuture-tf4639435s16868.html#a13250752
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.
Re: weird behaviour using ConnectFuture
Posted by chihiro <ga...@gmail.com>.
I solved my problem my adding a slight delay before calling
m_connector.connect( .. ).
It's working as expected now (fingers crossed).
chihiro.
--
View this message in context: http://www.nabble.com/weird-behaviour-using-ConnectFuture-tf4639435s16868.html#a13266712
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.