Skip navigation
14105 Views 24 Replies Latest reply: Apr 10, 2008 6:21 PM by ben RSS
Bronze 5 posts since
Dec 14, 2007
Currently Being Moderated

Dec 14, 2007 1:48 PM

http-bind polling interval check violates spec

According to XEP-0124 BOSH spec section 12 ([http://www.xmpp.org/extensions/xep-0124.html#poll]) , http-bind should check client polling interval only for "polling sessions".A polling session is defined at the beginning of section 12. There are 2 bugs involved:

  1. Openfire checks polling interval even for non-polling sessions.

  2. Even for polling sessions , Openfire ignores the clause in section 12 which says “and if the connection manager's response to the first request contained no stanzas."

The consequence of these bugs is unnecessary delay and breaks the essential technique of the BOSH spec which says "As soon as the client receives a response from the connection manager



it sends another request, thereby ensuring that the connection manager is (almost) always holding a request that it can use to 'push' data to



the client. ". A compliant client will be disconnected by Openfire http-bind incorrectly due to this incorrect check of polling interval.

To fix it, in HttpSession.java, method addConnection(), checkPollingInterval should be called only if this session is a polling session AND http-bind's response to the last poll

 request contained no stanzas. 




 

  • Alex Wenckus Jiver 1,029 posts since
    Jan 13, 2005
    Currently Being Moderated
    Dec 18, 2007 3:45 PM (in response to yilin)
    Re: http-bind polling interval check violates spec

    Openfire implements an older version of the XEP. http://www.xmpp.org/extensions/attic/xep-0124-1.5.html

     

    The conditions you mention are not in this version, Openfire will behave accordingly when it is upgraded to utilized the latest version of the XEP.

    • Bronze 2 posts since
      Dec 31, 2007

       

       

       

       

      AWenckus wrote:

      Openfire implements an older version of the XEP. http://www.xmpp.org/extensions/attic/xep-0124-1.5.html

       

      The conditions you mention are not in this version, Openfire will behave accordingly when it is upgraded to utilized the latest version of the XEP.

      That spec version also states that the client "SHOULD make a new request as soon as possible." That draft and the accepted spec work in the same way. It's how binding was designed from the start. The client submits an empty stanza, and waits for data. Upon receiving data it immediately connects again in the same way. The problem is when 2 messages are received a couple seconds apart (for example) - the client HAS to disconnect and reconnect to see the second message. The "checkPollingInterval()" in HttpSession.java is not smart enough to handle this case. 

       

       

      • Ryan Graham KeyContributor 1,940 posts since
        Jan 17, 2003
        Currently Being Moderated
        Jan 14, 2008 12:23 PM (in response to Jason)
        Re: http-bind polling interval check violates spec

        Hey Jason,

         

        We ran into the same problem while investigating some work for a potential client. As a potential work around instead of sending an empty stanza you can send a stanza with an empty presence packet. Such as the following:

         

        
        <body rid='1249243563'
              sid='SomeSID'
              xmlns='http://jabber.org/protocol/httpbind'>
           <presence></presence>
        </body>

         

        It's not an ideal solution, and we didn't investigate what (if any) side effects this may cause but it will keep Openfire from sending a 403 when it mistakenly thinks it is being polled too frequently.

         

        Hope that helps,

        Ryan

        • Bronze 33 posts since
          Jul 26, 2007
          Currently Being Moderated
          Jan 14, 2008 12:44 PM (in response to Ryan Graham)
          Re: http-bind polling interval check violates spec

           

          ryang wrote:

          Hey Jason,

           

          We ran into the same problem while investigating some work for a potential client. As a potential work around instead of sending an empty stanza you can send a stanza with an empty presence packet. Such as the following:

           

          <body rid='1249243563'
                sid='SomeSID'
                xmlns='http://jabber.org/protocol/httpbind'>
             <presence></presence>
          </body>
          

           

           

           

          It's not an ideal solution, and we didn't investigate what (if any) side effects this may cause but it will keep Openfire from sending a 403 when it mistakenly thinks it is being polled too frequently.

           

          Hope that helps,

          Ryan

          Ryan,

           

           

          Although a potential, temporary solution, the problem with this is that anyone with subscription to this user will receive a presence packet. This will cause these users to have to constantly poll the BOSH server, sending more presence packets and perpetuating the problem.

           

           

          • Ryan Graham KeyContributor 1,940 posts since
            Jan 17, 2003

            Although a potential, temporary solution, the problem with this is that anyone with subscription to this user will receive a presence packet. This will cause these users to have to constantly poll the BOSH server, sending more presence packets and perpetuating the problem.

             

            Like we've both said, it is just a potential, short-term solution and sending empty presence packets was the quickest way to implement it. If we had gone forward with an Openfire/BOSH solution we might have had the client send a custom iq packet to an Openfire plugin that would basically discard the packet upon receiving it.

             

            Ideally, of course, it would nice if the spec was fully implemented within Openfire. Have you studied the Openfire code to see how close it is to being 1.5 or 1.6 compliant? Are you aware of any BOSH testing tools that could be used to speed along development of making it standards compliant?

             

            Cheers,

            Ryan

  • Alex Wenckus Jiver 1,029 posts since
    Jan 13, 2005
    Currently Being Moderated
    Jan 15, 2008 12:08 AM (in response to yilin)
    Re: http-bind polling interval check violates spec

    Hmmm... I have checked the code and Openfire should only be checking the poll interval on polling connections:

     

    From HttpSession:

    
            if (isPoll) {
                checkPollingInterval();
            }
    

     

    This is checkPollingInterval:

    
        private void checkPollingInterval() throws HttpBindException {
            long time = System.currentTimeMillis();
            if (((time - lastPoll) / 1000) < maxPollingInterval) {
                throw new HttpBindException("Too frequent polling minimum interval is "
                        + maxPollingInterval + ", current interval " + ((time - lastPoll) / 1000),
                        BoshBindingError.policyViolation);
            }
            lastPoll = time;
        }
    

     

    isPoll is determined at line 514 in HttpSession:

    
    packetsToBeSent.size() <= 0
    

     

  • Alex Wenckus Jiver 1,029 posts since
    Jan 13, 2005
    Currently Being Moderated
    Jan 15, 2008 10:01 AM (in response to yilin)
    Re: http-bind polling interval check violates spec

    I have created the following issues:

     

    JM-1245

    JM-1246

     

    Cheers,

    Alex

    • dror Silver 111 posts since
      Aug 6, 2007
      Currently Being Moderated
      Jan 15, 2008 1:45 PM (in response to Alex Wenckus)
      Re: http-bind polling interval check violates spec

       

      I'm using a javascript client with openfire http-bind and xmpp.httpbind.client.requests.polling property set to 0!file:///C:/DOCUME%7E1/Ofir/LOCALS%7E1/Temp/moz-screenshot.jpg!

       

       

      I have issues with and I'm not sure if it is a client bug or related to this discussion.

       

       

      Can you please explain in what circumstances the current implementation of BOSH should end a client connection and what will be written in the error log?

       

       

      Is there a temporary workaround?

       

       

      In my case clients are being disconnected once per few hours with no evident reason.

       

       

      Thanks.

       

       

  • BenV Bronze 92 posts since
    Jan 25, 2007
    Currently Being Moderated
    Jan 24, 2008 8:29 AM (in response to yilin)
    Re: http-bind polling interval check violates spec

     

    With these changes in place, I feel like I am getting very close to having a functional AS 2.0 XIFF HttpBinding class working. This is excellent as it will allow our users who are behind restrictive firewalls to connect and chat on our site!

     

     

    I am currently using an HTTP proxy debugger to watch the traffic that goes back and forth between my client and Openfire and everything looks healthy. One connection is always being held open until either a packet is received or the 'wait' time expires, at which point my client opens another connection. I am not getting kicked for polling too fast due to the changes above. 

     

     

    I'll post any other problems I run into in this thread.

     

     

    • BenV Bronze 92 posts since
      Jan 25, 2007
      Currently Being Moderated
      Jan 24, 2008 9:38 AM (in response to BenV)
      Re: http-bind polling interval check violates spec

      One thing I forgot to mention, a change is required in HttpSession.java (line 767) to prevent some null pointer exceptions:

       

       

       

      
       
      public Deliverable(String text) {
        this.text = text;
        this.packets = new ArrayList<String>(); // <-- This used to be set to null, which caused NullPointerExceptions during enumeration in some cases
      }
       
      

       

       

      And another NullPointerException in HttpSession.java (line 701). This needed a if(packets != null) surrounding it due to the collection sometimes being null.

       

      private void failDelivery(Collection<Packet> packets) {
              if( packets != null ) {
                  for (Packet packet : packets) {
                      try {
                          backupDeliverer.deliver(packet);
                      }
                      catch (UnauthorizedException e) {
                          Log.error("Unable to deliver message to backup deliverer", e);
                      }
                  }
              }
          }
      

       

      • Bronze 13 posts since
        Feb 12, 2008
        Currently Being Moderated
        Feb 24, 2008 2:48 PM (in response to BenV)
        Re: http-bind polling interval check violates spec

         

        Hi BenV:

         

         

        Thanks for your changes. I read your post the other day, but didn't understand that you changes were what was required to fix my problem, until last night when I convinced myself that I wasn't actually going past the requests element in the response to my session being initiated. Then this afternoon I had a little trace in eclipse that convinced me that this was the right thing to do. I put in your null pointer fixes too, although I haven't yet experienced any null pointer exceptions.

         

         

        I found that I could test my javascript code using rhino and John Resig's env.js. I have attached the fixes that I made to  env.js as well as crypt.js from jsjac and my own javascript code for my HttpClientConnection.js and a test script BOSH.js that does the Romeo and Juliet scene from the specifications. Hopefully this is as helpful to someone else as your fixes were to me.

         

         

        thanks

         

         

        Rich

         

         

        Attachments:

More Like This

  • Retrieving data ...

Bookmarked By (0)