I changed the code to do the following when the disconnect method is called in my IoHandlerAdapter.

// defined at top of class.
private SocketConnector connector;
private IoSession session;
static final int CONNECT_TIMEOUT = 3000;

// inside of the disconnect method.
System.out.println("here 1.");
CloseFuture cf = session.close(true);
System.out.println("here 2.");
cf.awaitUninterruptibly(CONNECT_TIMEOUT);
System.out.println("here 3.");
connector.dispose();
System.out.println("here 4.");

The "here 1" and 2 are printed then a 60 second pause.
Then the command shell prompt appears.
The "here 3" and 4 are not printed.

So the call to cf.awaitUninterruptibly(CONNECT_TIMEOUT); blocks for 60 seconds.

Do I need to do the connector.dispose() before the do the wait?
I am probably doing stuff out of order I am thinking.

Kelly

Emmanuel Lecharny wrote:
Kelly Wiles wrote:
Hi

When I close a session using the call
   session.close(true).awaitUninterruptibly(3000);

The session does not close for 60 seconds.
What do you mean ? Have you checked the CloseFuture.isClosed() result ?
CloseFuture closeFuture = session.close(true);
closeFuture.awaitUninterruptibly(3000);

if (closeFuture.isDone()) {
 // The session is closed...
}

Is this the right way to shutdown a connection?
Yes, it will close the session.

I am trying to send two messages to a server then once the responses have returned I shutdown my client program. But the client program does not quit for 60 seconds.
You also have to dispose the Connector. Closing the session won't be enough.

------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.339 / Virus Database: 270.12.53/2156 - Release Date: 06/05/09 06:24:00


--
Schedule A Meeting
Meeting Management Software
http://sam.kdkhome.com/

Tabby Install and Tabby Editor for Eclipse
Create application install programs easily.
http://www.tabbyinstall.com/

Jar Compiler an Eclipse Plugin
Compile Java Jar files into a native executable.
http://www.tabbyinstall.com/jarc/JarCompiler.html

ISO Builder an Eclipse Plugin
Create CDROM ISO images.
http://www.tabbyinstall.com/isobuilder/ISOBuilder.html

ProtoTiger for the Apache Mina project.
Generates client/server source code from GUI design.
http://www.tabbyinstall.com/prototiger/ProtoTiger.html

Reply via email to