powered by Jive Software

Smack 4.4.0: Smack BOSH implementation and login failure

aTalk is trying to add BOSH support using smack-Bosh library, but facing problem. As I am still no familiar with the whole BOSH setup protocol, so not sure whether problem is due to aTalk implementation or smack-Bosh library.

Below is the debug log for initial login via BOSH on aTalk. As smack-Bosh only provides log for received messages from server, I have modified BoshClient class to dump the BOSH send messages from client. As the debug messages from SEND/RECEIVED are not sync, the captured BOSH response message in the log may come before request from server (by few tens of ms).

During aTalk login, based on the ConnectionListener, it receives callback only for:
connected(XMPPConnection connection)
immediately after that:
connectionClosedOnError(Exception exception)

However from the debug log, it did received the authentication <success/> response from server.
According to the XEP spec:
XEP-0206: XMPP Over BOSH

I see that smack-BOSH ends the whole login process at
Example 8. Restart request

I did not see any sent/received messages on
Example 9. Result of restart request
Example 10. Resource binding request
Example 11. Resource binding result

Please advice what can the possible cause and resolution.

============= aTalk Bosh message log =============
2019-08-19 13:43:51.311 2875-4349/org.atalk.android D/(BOSHClient.java:509)#send: BOSH SEND: <body ver='1.8' wait='60' xmpp:version='1.0' rid='2661460474158804' xmlns:xmpp='urn:xmpp:xbosh' hold='1' xml:lang='en' ack='1' to='atalk.sytes.net' xmlns='http://jabber.org/protocol/httpbind'></body>
2019-08-19 13:43:51.935 2875-4353/org.atalk.android D/SMACK: RECV (0): 
    <body xmpp:version='1.0' authid='2830367793981677772' xmlns='http://jabber.org/protocol/httpbind' sid='63c1d5f6a213aec3fc20fbf5059e80f980f01930' wait='60' ver='1.11' polling='2' inactivity='30' hold='1' xmpp:restartlogic='true' requests='2' secure='true' maxpause='120' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams' from='atalk.sytes.net'>
      <stream:features>
        <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
          <mechanism>
            PLAIN
          </mechanism>
          <mechanism>
            SCRAM-SHA-1
          </mechanism>
          <mechanism>
            X-OAUTH2
          </mechanism>
        </mechanisms>
        <register xmlns='http://jabber.org/features/iq-register'/>
      </stream:features>
    </body>
2019-08-19 13:43:51.972 2875-4363/org.atalk.android D/(BOSHClient.java:509)#send: BOSH SEND: <body rid='2661460474158805' sid='63c1d5f6a213aec3fc20fbf5059e80f980f01930' xmlns='http://jabber.org/protocol/httpbind'></body>
2019-08-19 13:43:52.296 2875-4349/org.atalk.android D/(BOSHClient.java:509)#send: BOSH SEND: <body rid='2661460474158806' ack='2661460474158804' sid='63c1d5f6a213aec3fc20fbf5059e80f980f01930' xmlns='http://jabber.org/protocol/httpbind'><auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='SCRAM-SHA-1'>biwsbj1zd29yZGZpc2gscj0pdnU+ZXZNaDlxKGdMOF9LdHJoa30zQSViJEJkSnE9aA==</auth></body>
2019-08-19 13:43:52.502 2875-4353/org.atalk.android D/SMACK: RECV (0): 
    <body xmlns='http://jabber.org/protocol/httpbind'/>
2019-08-19 13:43:53.184 2875-4352/org.atalk.android D/(BOSHClient.java:509)#send: BOSH SEND: <body rid='2661460474158807' ack='2661460474158805' sid='63c1d5f6a213aec3fc20fbf5059e80f980f01930' xmlns='http://jabber.org/protocol/httpbind'><response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>Yz1iaXdzLHI9KXZ1PmV2TWg5cShnTDhfS3RyaGt9M0ElYiRCZEpxPWhWZDkrUDdmMExVZ054c05XbE15RE1RPT0scD1jY21YTzgvdWJBbndRb2pVRWpWNy9YbzdEVm89</response></body>
2019-08-19 13:43:53.205 2875-4353/org.atalk.android D/SMACK: RECV (0): 
    <body xmlns='http://jabber.org/protocol/httpbind'>
      <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        cj0pdnU+ZXZNaDlxKGdMOF9LdHJoa30zQSViJEJkSnE9aFZkOStQN2YwTFVnTnhzTldsTXlETVE9PSxzPTVXVENHSnk1dk1FUWJpNmZWRVJ1S0E9PSxpPTQwOTY=
      </challenge>
    </body>

2019-08-19 13:43:53.234 2875-4361/org.atalk.android D/(BOSHClient.java:509)#send: BOSH SEND: <body xmpp:restart='true' rid='2661460474158808' xmlns:xmpp='urn:xmpp:xbosh' sid='63c1d5f6a213aec3fc20fbf5059e80f980f01930' ack='2661460474158806' to='atalk.sytes.net' xmlns='http://jabber.org/protocol/httpbind'></body>
2019-08-19 13:43:53.246 2875-4353/org.atalk.android D/SMACK: RECV (0): 
    <body xmlns='http://jabber.org/protocol/httpbind'>
      <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
        dj05MFo1RzRpR1hQSU9pbkpSQVlVYmpYWGp6MjA9
      </success>
    </body>
2019-08-19 13:43:53.298 2875-4353/org.atalk.android D/SMACK: RECV (0): 
    <body xmpp:version='1.0' authid='7722635872794287839' xmlns='http://jabber.org/protocol/httpbind' xmlns:stream='http://etherx.jabber.org/streams' xmlns:xmpp='urn:xmpp:xbosh'>
      <stream:features>
        <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/>
        <session xmlns='urn:ietf:params:xml:ns:xmpp-session'>
          <optional/>
        </session>
        <c ver='3jzWy2u2gNa0IkJrebCCN7MEias=' node='http://www.process-one.net/en/ejabberd/' hash='sha-1' xmlns='http://jabber.org/protocol/caps'/>
        <sm xmlns='urn:xmpp:sm:2'/>
        <sm xmlns='urn:xmpp:sm:3'/>
        <ver xmlns='urn:xmpp:features:rosterver'/>
        <csi xmlns='urn:xmpp:csi:0'/>
      </stream:features>
    </body>
2019-08-19 13:43:53.381 2875-4363/org.atalk.android D/(BOSHClient.java:509)#send: BOSH SEND: <body rid='2661460474158809' sid='63c1d5f6a213aec3fc20fbf5059e80f980f01930' xmlns='http://jabber.org/protocol/httpbind'></body>

2019-08-19 13:44:21.868 2875-4403/org.atalk.android W/aTalk: [92953] org.jivesoftware.smack.AbstractXMPPConnection.callConnectionClosedOnErrorListener() Connection XMPPBOSHConnection[not-authenticated] (0) closed with error
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toUpperCase(java.util.Locale)' on a null object reference
        at org.jivesoftware.smack.packet.StanzaError$Type.fromString(StanzaError.java:350)
        at org.jivesoftware.smack.util.PacketParserUtils.parseError(PacketParserUtils.java:808)
        at org.jivesoftware.smack.util.PacketParserUtils.parseError(PacketParserUtils.java:787)
        at org.jivesoftware.smack.bosh.XMPPBOSHConnection$BOSHPacketReader.responseReceived(XMPPBOSHConnection.java:522)
        at org.igniterealtime.jbosh.BOSHClient.fireResponseReceived(BOSHClient.java:1612)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1147)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:1001)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:102)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1730)
        at java.lang.Thread.run(Thread.java:764)
2019-08-19 13:44:21.875 2875-4361/org.atalk.android I/aTalk: [92943] org.jivesoftware.smack.AbstractXMPPConnection.notifyConnectionError() Connection was already disconnected when attempting to handle org.igniterealtime.jbosh.BOSHException: Terminal binding condition encountered: remote-stream-error  (Encapsulated transport protocol error.)
    org.igniterealtime.jbosh.BOSHException: Terminal binding condition encountered: remote-stream-error  (Encapsulated transport protocol error.)
        at org.igniterealtime.jbosh.BOSHClient.checkForTerminalBindingConditions(BOSHClient.java:1396)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1172)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:1001)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:102)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1730)
        at java.lang.Thread.run(Thread.java:764)
2019-08-19 13:44:51.877 2875-4349/org.atalk.android E/(ProtocolProviderServiceJabberImpl.java:617)#register: Error registering: No response received within reply timeout. Timeout was 30000ms (~30s). While waiting for account authenticated

I would not recommend doing so right now. First smack-bosh is unmaintained horrible code and probably full of bugs. Second, I do plan to change how Smack does with the different transport mechanisms in the coming months™. I suggest to wait until that arrvies before you start adding support for BOSH.

Thanks for the info. aTalk has actually completed the implementation for BOSH support.
Will just hide the BOSH option for user selection

Looking forward for the new smack release with BOSH support.