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.
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:
If the receiver is offline(while the server still assumes he is online), the code:
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.
Hi Tom, You have any thoughts on this issue?
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.
Explicitly check the underlying connection and throw an IOException if the peer has dropped/reset the connection.