Hi mat, On 7/28/07, mat <[EMAIL PROTECTED]> wrote: > On 7/28/07, Gaston Dombiak <[EMAIL PROTECTED]> wrote: > > > > Hey Trustin, > > > > I noticed many times (specially when behind a NAT device) that sometimes > > when a socket connection was lost/closed it's like the TCP layer does not > > inform the JVM about the event. So the JVM thinks that the socket is fine > > and even after writing some data (before the write queue gets full) the JVM > > will not get any IO exception so it will still think that the socket is > > alive. The only workarounds we applied (at the application level) were 1) > > add heartbeats that will eventually (hopefully) will fill up the write queue > > and get an IO exception or 2) close socket that have not "sent" any data to > > the server. I think that #1 is not 100% safe so #2 will eventually close the > > "assumed" dead connection. > > > Will setWriteTimeout solve uncaught IO exception problem? Or a > setIdleTime for Read and Write and send ping-pong?
Yep, both will work. I'd use both parameters for maximum safety. > > ----- Original Message ----- > > From: "Trustin Lee" <[EMAIL PROTECTED]> > > To: dev@mina.apache.org > > Sent: Friday, July 27, 2007 10:11:14 AM (GMT-0800) America/Los_Angeles > > Subject: Re: Out Of Memory Problem Again > > > > On 7/28/07, mat <[EMAIL PROTECTED]> wrote: > > > After further research, I found out if one client disconnection was not > > > caught and session.write() kept got called. Which causes the OOM? Is > > that > > > possible? > > > > Yes. You have to make sure if the connection is alive and write > > operation was successful. You can check if the connection is alive by > > calling IoSession.isClosing(), and WriteFuture.isWritten() for write > > operations. > > > Should that be session.isConnected()? However, if disconnection doesn't get > caught, session.isConnected() will never work since you never do > session.close(), right? SetWriteTimeout works for this issue, right? Why > WriteFuture.isWritten()?? Right, it was IoSession.isConnected(). Sorry for the confusion. :) WriteFuture.isWritten() returns false if the connection is closed already or there was an I/O exception. HTH, Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6