BOSH connection in 4.7.1 fails with invalid rid error

We have the storphe openfire client which creates the http-bind request once in 30 seconds and everything works fine. After few hours of keeping the session idle, the response for the http-bind gives the old values of rid value not the one requested.



Eg:
Request: <body rid='771796934' xmlns='http://jabber.org/protocol/httpbind' sid='zgnmepnk3'/>
Response: <body xmlns='http://jabber.org/protocol/httpbind' ack='771796934'>
</body>

Request: <body rid='771796935' xmlns='http://jabber.org/protocol/httpbind' sid='zgnmepnk3'/>
Response: <body xmlns='http://jabber.org/protocol/httpbind' ack='771796935'>
</body>


Request: <body rid='771796936' xmlns='http://jabber.org/protocol/httpbind' sid='zgnmepnk3'/>
Response: <body xmlns='http://jabber.org/protocol/httpbind' ack='771796936'>
</body>


Request: <body rid='771796937' xmlns='http://jabber.org/protocol/httpbind' sid='zgnmepnk3'/>
Response: <body xmlns='http://jabber.org/protocol/httpbind' ack='771796935'>
</body>

Request: <body rid='771796938' xmlns='http://jabber.org/protocol/httpbind' sid='zgnmepnk3'/>
Response: <body xmlns='http://jabber.org/protocol/httpbind' ack='771796935'>
</body>


And the session closed with the error saying not-found.
Request: <body rid='771796939' xmlns='http://jabber.org/protocol/httpbind' sid='zgnmepnk3'/>
Response: <body xmlns="http://jabber.org/protocol/httpbind" type="terminate" condition="item-not-found"/>

Looks like there are some concurrency issue in HttpSession.java code in openfire. This should be fixed.

i am also facing this issue after some hours …

I was having this issue in 4.4.4 openfire, upgrading to 4.7.1 fixed the issue. I need to change the heading of the thread to “BOSH connection in 4.4.4 fails with invalid rid error” but its not allowing now.

The problem happens in the onTimeout method of HttpSession.java

This fix on top of HttpSession.java in 4.4.4 fixes the actual problem.

-                    deliverOnTimeout(connection);
+                    try {
+                        deliverOnTimeout(connection);
+                    } catch (IOException e) {
+                        setLastResponseEmpty(true);
+                        // This connection timed out we need to increment the request count
+                        if (connection.getRequestId() != lastRequestID + 1) {
+                            Log.warn( "Unexpected RID error - caught IO Exception." + rid + " for session " + streamID + " lastRequestID "+ lastRequestID);
+                            throw new IOException("Unexpected RID error.");
+                        }
+                        lastRequestID = connection.getRequestId();
+                        Log.warn("------- Caught an exception but - set the lastRequestID proper lastRequestID ->"+lastRequestID);
+                        throw new IOException("Unexpected RID error. corrected lastRequestID.");
+                    }