Yes.... that's exactly what I have experienced. It hangs if you call dispose inside of the operationComplete. I kicked off another thread inside just to do the dispose. Any other good ways?
Thanks, Yong -----Original Message----- From: Emmanuel Lcharny [mailto:[email protected]] Sent: Friday, January 15, 2010 1:53 AM To: [email protected] Subject: Re: Problem closing a session David Rosenstrauch a écrit : > On 01/14/2010 04:10 PM, Leandro Casadei wrote: >> Hi, I'm having a little problem using MINA as a client. >> When I'm done sending messages, I call the following code: >> >> >> CloseFuture future = session.close(true); >> future.awaitUninterruptibly(); >> connector.dispose(); >> >> The problem is that the second line keeps waiting forever, causing file >> descriptors leaks. >> >> My questions would be: >> What could be the reason for this method to hang? >> The server isn't doing something this method expect? >> >> Btw: The server is also using MINA. >> >> Thanks. > > I've been handling session close as follows, and it's been working well: > > CloseFuture closeFuture = getSession().close(closeImmediately); > closeFuture.addListener(new CloseSessionListener()); > ... > class CloseSessionListener implements IoFutureListener<CloseFuture> { > public void operationComplete(CloseFuture future) { > <do cleanup here> > } > } > > HTH, > > DR Thanks David. I think it's the way to go, with one little trick : you must not do the dispose() in the operationComplete(), or the client will hang. I think we should document this in the FAQ, as this is a frequent question.
