Thanks. I was executing some logic in callback methods, who are executed in a separated IoProcessor thread. As logic was executed in a thread to process asynchronous callbacks, when logic tried to close session, an exception was thrown
I'll try don't execute logic code in callbacks methods 2013/7/16 Emmanuel Lécharny <elecha...@gmail.com> > Le 7/16/13 11:29 AM, Jose María Zaragoza a écrit : > > Hello: > > > > I'm using Mina 2.0.7 and I'm getting this error where close a session > > > > > > java.lang.IllegalStateException: DEAD LOCK: IoFuture.await() was invoked > > from an I/O processor thread. Please use IoFutureListener or configure a > > proper thread model alternatively. > > > > at > > > org.apache.mina.core.future.DefaultIoFuture.checkDeadLock(DefaultIoFuture.java:240) > > > > at > > > org.apache.mina.core.future.DefaultIoFuture.await0(DefaultIoFuture.java:210) > > > > at > > > org.apache.mina.core.future.DefaultIoFuture.awaitUninterruptibly(DefaultIoFuture.java:153) > > > > > > I'm closing session with the next code: > > > > if (this.session != null) > > { > > > > CloseFuture future = this.session.close(false); > > future.await(10000); > > if (!future.isClosed()) > > throw new Exception("Disconnect timeout after waiting 10 seconds"); > > } > > > > What could be the right solution? > > You can't close the session and wait for the future to be completed, as > the future will be updated by the thread you are on. > > Let me explain what's going on : > - you are on a thread that handle the session. You require this session > to be closed. > - the current thread will update a set with the session to be closed > - the main server thread will process this set when it will be able to > do it (ie, probably in the next few ms after you closed the session) > - it's very likely that the main server thread will reuse the same > thread than the one you hold for the session (unless you specifically > tell the server to manage threads differently, it will *always* use the > same thread for a given session. If you have, say, three IoProcessor, > you will have three threads created, and all the sessions will be evenly > spreaded on those three threads, but each session will always use the > same thread) > - and as you hold the thread waiting for the future to be completed, > this thread can't be used to update the future status by the main server > thread... > > what exactly are you trying to do with the check on the session timeout > ? You can most certainly use the idle event to manage the timeout... > > > -- > Regards, > Cordialement, > Emmanuel Lécharny > www.iktek.com > >