On Thursday 17 January 2008 04:52:38 Trustin Lee wrote:
i have update to the latest snapshot code (16012008) and have the same problem.
> On Jan 17, 2008 2:58 AM, Luc Willems <[EMAIL PROTECTED]> wrote:
> > the connecting thread will block "forever" when i replace the
> > cf.awaitUninterruptibly() with cf.await() :-(

> Doesn't cf.awaitUninterruptibly() with no parameter also block forever?

i 'll  have to try that. i used the awaitUninterruptibly(timeout) with timeout 
values of 40 sec and connector.setConnectTimeout() of 30 sec.
still connectfuture returns after 40 seconds with no IoSession


> > somehow, the connection is not notified to the connectFuture.
> > in my logfile i can see that connection was established in very short
> > time (< 1sec)awaitUninterruptibly()
here is some logging i get in debug :

2008-01-17 
08:14:55,616|main|DEBUG|WVConnectionFactory.getConnection(82)||getConnection : 
wit-admin.iplab.atea.be:4548
2008-01-17 08:14:55,618|main|DEBUG|WVConnectionFactory.getConnection(94)||wait 
for connection finished
2008-01-17 08:14:55,620|NioSocketConnector-1|INFO 
|WVIoHandler.initializeSession(315)|4|63: initialise session (0x01261342: nio 
socket, client, /172.16.58.131:24848 => 
wit-admin.iplab.atea.be/172.16.58.136:4548)
2008-01-17 08:14:55,637|NioProcessor-19|INFO 
|TestAgent.sessionCreated(94)|63|connected CSP11Agent
2008-01-17 
08:15:25,643|NioProcessor-19|DEBUG|DecodingStateMachine.finishDecode(125)||Ignoring
 the exception caused by a closed session.
org.apache.mina.filter.codec.ProtocolDecoderException: Unexpected end of 
session while waiting for a HTTP version field.
        at 
org.apache.mina.filter.codec.http.HttpVersionDecodingState.finishDecode(HttpVersionDecodingState.java:85)

basicly , connection is created in  0.04 sec but after 30 sec the server closes 
the connection because no request is send. this triggers the  Http protocol 
exception wich is ignored .
the reason for this is that  the connectFuture is stil waiting .....


> Does it mean that the connection is closed immediately?  Do you get
> notified with sessionClosed() event?
i'll have to check this. i' modifying the code to log all related IO events to 
closely see what's going on with all my connections.

> What filters are you using?
my connector stack looks like this:
 
        connector = new NioSocketConnector();
        int coresize=10;
        Executor pool=Executors.newFixedThreadPool(coresize,new 
WVIoThreadFactory(iofactorycount.incrementAndGet()));
        final ExecutorFilter executor = new ExecutorFilter(pool);

        connector.getFilterChain().addLast("http",new ProtocolCodecFilter(new 
HttpCodecFactory()));
        connector.getFilterChain().addLast("threadPool", executor);
        connector.getFilterChain().addLast("wv", new WVPlainTextFilter());
        //connector.getFilterChain().addLast("logger", new WVLogger(true));
        connector.setHandler(new DelegateIoHandler());
        connector.getSessionConfig().setTcpNoDelay(true);
        connector.getSessionConfig().setBothIdleTime(5);
        connector.getSessionConfig().setKeepAlive(true);
        connector.setConnectTimeout(CONNECT_TIMEOUT);

> Trustin

I 'm also a little bit puzzeled how to handle "remote" close for HTTP NIO 
connections.
For my client software , if a connection is closed , he must reopen and retry. 
but if i do ioSession.write(object) and the connection is closed before data is 
send over 
how do i know that this is the case ? 

at the moment i use following aproche :
        - check if connection is available , use it else create new IoSession 
(in case of first HTTP request)
        - writing to this Iosession 
        - check writeFuture if ok 
        - if nok , close connection and retry a few seconds later.
        - if retry fails , send IoException.

in case a connection is closed at the same time when my thread is writing to 
the session , 
i would expect that i get a error back from the write future ?
 
        luc

Reply via email to