Verify if there were packets pending to be sent and decide what to do with them
Description
Environment
is related to
Activity

Tom Evans April 26, 2014 at 9:00 PM
Explicitly check the underlying connection and throw an IOException if the peer has dropped/reset the connection.

Tom Evans April 26, 2014 at 8:34 PMEdited
Since we are using an asynchronous messaging model (via NIO), it makes sense to check whether the peer is still connected before attempting to send a packet. It appears this is what the underlying Mina implementation does, but because the NIOConnector does not wait to check the resulting WriteFuture instance, the backupDeliverer is not invoked (the IOException is effectively suppressed in another thread).
I can make the corresponding change, but note that this is a critical component of the Openfire engine and we will want to test thoroughly.

Daryl Herzmann April 26, 2014 at 6:59 PM
Hi Tom, You have any thoughts on this issue?

Haohuan Li March 22, 2013 at 9:53 AM
I just looked into OpenFire source code v3.8.1. I found that the cause of the issue lies in the MINA lib that was reused by OpenFire. In NIOConnection.java, line 263:
http://fisheye.igniterealtime.org/browse/openfire/trunk/src/java/org/jivesoftware/openfire/nio/NIOConnection.java?r2=12983&u=3&r1=12983&r=13001
If the receiver is offline(while the server still assumes he is online), the code:
ioSession.write(buffer)
should have thrown an exception. But actually, no exception is thrown. The variable ioSession is an instance of class: org.apache.mina.common.IoSession, which is a component of Apache MINA project. Maybe this issue should be reported upwards to MINA project.
Looks like someone was already planning this. Todo in the source: http://fisheye.igniterealtime.org/browse/openfire/trunk/src/java/org/jivesoftware/openfire/nio/ConnectionHandler.java?r1=12983&r2=12983&u=3#to138
There are ideas that this should help with messages being discarded while clients lose their connection.
This ticket needs better name and description.