Le 11/19/13 1:59 PM, Nitin a écrit : > Dear All, > > We have developed one server using Apache MINA V2.0.4 where multiple > vendors connect and send the messages which needs to be processed and then > response have to be sent back to vendor. Currently we have put a strategy > that vendor has to send one message per connection and after getting > response or timeout vendor has to close the connection.
So far, so good. > > > > But after sometime we realized that some of the vendors are not > closing connections and due that many sessions are remaining idle. To tackle > this we started using the sessionIdle(IoSession session, IdleStatus status) > event for each vendor connection and we use to close the session in this > event with session.close(true); That's the right way to do it. > > > > But then I saw this link where it was saying that session.close(true) may > cause issue http://comments.gmane.org/gmane.comp.apache.mina.user/4616 No. > > so we changed it to session.close(false); Wrong. It will wait for all the pending messages to be sent to the (vanished) client. That means forever. > > > > Now we are facing issue of Broken pipes. Suddenly we start getting below > ERROR and it will keep coming continuously and fills the log files only with > this error. > > > > java.io.IOException: Broken pipe > > at sun.nio.ch.FileDispatcher.write0(Native Method) It's plain normal : the server is trying to send messages to a now disconnected server. And it will try again and again. > > > We have observed that once above issue comes we end up in restarting our > MINA based server or sometimes the OS to bring it back to working state. Yes. > > I would like to know in details how I can identify the idle session and with > our strategy of one message per connection how we can identify the idle > sessions and close them peacefully. Again, just do what you suggested : manage the sessionIdle() event and do close(true) (ie, clise with imediate effect, discarding the pending messages). > > > > Thanks in advance. Looking for concrete solution. close(true) and sessionIdle managed is a concrete solution to your problem. Don't read threads and deduce that there is a problem. If you have an issue with close(true) and idle management, then please post on this mailing list so that we can help you with valid solutions. Ah, btw, I urge you to switch to 2.0.7. 2.0.4 is more than 2 years old, and many bugs have been fixed since. Thnks for using MINA ! -- Regards, Cordialement, Emmanuel Lécharny www.iktek.com