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.

aTalk has restarted the testing of BOSH connection using smack libraries built based on smack master repository source. Following is the observation on aTalk as per XEP-0206 standard:

Example 10. Resource binding request

It seems that Bosh response to Resource binding request is complete (as shown in the log below) i.e.
the iq stanza is missing:

  <iq id='bind_1'
      type='set'
      xmlns='jabber:client'>
    <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
      <resource>httpclient</resource>
    </bind>
  </iq>

Also currently there is no debug message for the stream data sent by BoshClient#send(). Appreciate if smack team would provide the debug log messages to ease the app development.

Edited by cmeng (20191017): actually already included in code. Just need to add writer.flush();

        client.addBOSHClientRequestListener(new BOSHClientRequestListener() {
            @Override
            public void requestSent(BOSHMessageEvent event) {
                if (event.getBody() != null) {
                    try {
                        writer.write(event.getBody().toXML());
                        writer.flush();
                    } catch (Exception e) {
                        // Ignore
                    }
                }
            }
        });
======= aTalk debug log ========
2019-10-14 12:04:38.900 29479-29961/org.atalk.android D/SMACK: RECV (2): 
    <body xmpp:version='1.0' authid='13214538452407995133' 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-10-14 12:04:38.993 29479-29964/org.atalk.android D/(BOSHClient.java:509)#send: BOSH SEND: <body rid='4412246004026578' sid='67fb7d1e8ff438491c809d6d92a2ec98e06e26bd' xmlns='http://jabber.org/protocol/httpbind'></body>

2019-10-14 12:05:08.796 29479-29961/org.atalk.android D/SMACK: RECV (2): 
    <body type='terminate' condition='remote-stream-error' xmlns:stream='http://etherx.jabber.org/streams' xmlns='http://jabber.org/protocol/httpbind'>
      <stream:error>
        <connection-timeout xmlns='urn:ietf:params:xml:ns:xmpp-streams'/>
        <text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
          Idle connection
        </text>
      </stream:error>
    </body>
````Preformatted text`

aTalk manages to get the BOSH Connection login working with the following patch applies to
XMPPBOSHConnection.java file.

XMPPBOSHConnection.patch (3.2 KB)

However it works until the following OMEMO exception.
Need investigation.

============== aTalk BOSH Connection debug log =============
2019-10-18 13:29:06.643 4732-5086/org.atalk.android D/SMACK: SENT (0): 
    <body rid='6089744892666124' sid='d57be2adf43b95d223f76e45a28b786d7a5b5227' xmlns='http://jabber.org/protocol/httpbind'>
      <iq xmlns='jabber:client' id='62U8K-91' type='set'>
        <pubsub xmlns='http://jabber.org/protocol/pubsub'>
          <publish node='eu.siacs.conversations.axolotl.bundles:595475613'>
            <item xmlns='http://jabber.org/protocol/pubsub'>
              <bundle xmlns='eu.siacs.conversations.axolotl'>
                <signedPreKeyPublic signedPreKeyId='4'>
                  BVqedxs4xxfZy3JemrbYVzU2BeZNXMXGUGy18bXeGf1V
                </signedPreKeyPublic>
                <signedPreKeySignature>
                  n9+hlTU0Acw2uF9bRMQLMczgcczGdu++TDurFhiwIpQ/thYDqt3/9GXcBnCh32rZ+icT7ii7ZbsvxKb/elpJgw==
                </signedPreKeySignature>
                <identityKey>
                  BWl44UKxSDEAYKMuzSRsavIyPk2FadrYm2K3tdQvpKEp
                </identityKey>
                <prekeys>
                  <preKeyPublic preKeyId='1'>
                    Ba2lvLjZha56q41hEd0N7Ta/Ci5Pg+fg+slt9HDlSnQ0
                  </preKeyPublic>
                  <preKeyPublic preKeyId='2'>
                    BWaVj+duXWK1s3gps8VfCycJD7cM05CukauYdXT2yMVT
                  </preKeyPublic>
                  <preKeyPublic preKeyId='3'>
                    BYrUzMZE2Njj54tWVg+OmRTQ+oaePJ2B/StBZ6ry2d8F
                  </preKeyPublic>
                  <preKeyPublic preKeyId='4'>
                    BSlUabLRfXEpoMhZXLVe73kQofthtLPKYJSkVId2E5Vh
                  </preKeyPublic>
....
                  <preKeyPublic preKeyId='22'>
                    Bb2YpRkhiHoPgrRNEL2ubE5SgoK3pVyv97bx92GYJ0pU
                  </preKeyPublic>
                  <preKeyPublic preKeyId='23'>
                    BTUnWUdS2w3V0FHrdO9W5/vZcEbQh9RErid7T0yzAzUO
                  </preKeyPublic>
                  <preKeyPublic preKeyId='24'>
                    BaNrEorxFVd+yKsCfnTc6cltqaVhj/P11f5iPVua1fk8
2019-10-18 13:29:06.644 4732-5086/org.atalk.android D/SMACK: SENT (0): 
2019-10-18 13:29:06.646 4732-5078/org.atalk.android D/NetworkManagementSocketTagger: tagSocket(74) with statsTag=0xffffffff, statsUid=-1
2019-10-18 13:29:06.669 4732-5078/org.atalk.android I/NetworkManagementSocketTagger: untagSocket(74)
2019-10-18 13:29:06.669 4732-5078/org.atalk.android I/System.out: RequestProcessor[31289853]: Receive thread 1 calls detatch()
2019-10-18 13:29:06.689 4732-5086/org.atalk.android E/(AndroidOmemoService.java:123)#initializationFailed: OmemoManager init failed
    org.jivesoftware.smack.SmackException$NotConnectedException: The connection XMPPBOSHConnection[swordfish@atalk.sytes.net/atalk] (0) is no longer connected while waiting for response with IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=62U8K-91)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (ignoreResourcepart): swordfish@atalk.sytes.net, FromMatchesFilter (full): atalk.sytes.net)) because of org.igniterealtime.jbosh.BOSHException: Could not parse body:
    <?xml version='1.0'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <h1>400 Bad Request</h1>
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:276)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
        at org.jivesoftware.smackx.pubsub.LeafNode.publish(LeafNode.java:330)
        at org.jivesoftware.smackx.pubsub.LeafNode.publish(LeafNode.java:309)
        at org.jivesoftware.smackx.pubsub.PubSubManager.tryToPublishAndPossibleAutoCreate(PubSubManager.java:452)
        at org.jivesoftware.smackx.pep.PepManager.publish(PepManager.java:165)
        at org.jivesoftware.smackx.omemo.OmemoService.publishBundle(OmemoService.java:592)
        at org.jivesoftware.smackx.omemo.OmemoService.init(OmemoService.java:260)
        at org.jivesoftware.smackx.omemo.OmemoManager.initialize(OmemoManager.java:251)
        at org.jivesoftware.smackx.omemo.OmemoManager$2.run(OmemoManager.java:266)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: org.igniterealtime.jbosh.BOSHException: Could not parse body:
    <?xml version='1.0'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <h1>400 Bad Request</h1>
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:132)
        at org.igniterealtime.jbosh.StaticBody.fromString(StaticBody.java:114)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.awaitResponse(ApacheHTTPResponse.java:246)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.getBody(ApacheHTTPResponse.java:192)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1122)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727)
        	... 1 more
     Caused by: java.lang.IllegalStateException: Root element was not 'body' in the 'http://jabber.org/protocol/httpbind' namespace.  (Was 'h1' in '')
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:98)
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:132) 
        at org.igniterealtime.jbosh.StaticBody.fromString(StaticBody.java:114) 
        at org.igniterealtime.jbosh.ApacheHTTPResponse.awaitResponse(ApacheHTTPResponse.java:246) 
        at org.igniterealtime.jbosh.ApacheHTTPResponse.getBody(ApacheHTTPResponse.java:192) 
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1122) 
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998) 
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100) 
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727) 
2019-10-18 13:29:06.697 4732-5094/org.atalk.android W/aTalk: [88438] org.jivesoftware.smack.AbstractXMPPConnection.callConnectionClosedOnErrorListener() Connection XMPPBOSHConnection[swordfish@atalk.sytes.net/atalk] (0) closed with error
    org.igniterealtime.jbosh.BOSHException: Could not parse body:
    <?xml version='1.0'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <h1>400 Bad Request</h1>
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:132)
        at org.igniterealtime.jbosh.StaticBody.fromString(StaticBody.java:114)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.awaitResponse(ApacheHTTPResponse.java:246)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.getBody(ApacheHTTPResponse.java:192)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1122)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.IllegalStateException: Root element was not 'body' in the 'http://jabber.org/protocol/httpbind' namespace.  (Was 'h1' in '')
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:98)
        at org.igniterealtime.jbosh.StaticBody.fromString(StaticBody.java:114) 
        at org.igniterealtime.jbosh.ApacheHTTPResponse.awaitResponse(ApacheHTTPResponse.java:246) 
        at org.igniterealtime.jbosh.ApacheHTTPResponse.getBody(ApacheHTTPResponse.java:192) 
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1122) 
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998) 
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100) 
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727) 
        at java.lang.Thread.run(Thread.java:764)

Finally found the causes of the problem in BOSH connection (see below log)

The reason is AbstractXMPPConnection#incomingStreamXmlEnvironment parameter is initialized with called from XMPPTCPConnection

parsePackets {
    case "stream":
        onStreamOpen(parser);
    break;
}

on receive of <Steam:stream/> Nonza which is not present when using BOSHConnection.
Below is the patch to make BoshConnection work. The patch includes a temporary patch (for aTalk) to init the incomingStreamXmlEnvironment which requires further work by smack team.

XMPPBOSHConnection.patch (4.9 KB)

============= aTalk BoshConnection log =============
2019-10-18 18:12:34.792 32593-32722/org.atalk.android W/aTalk: [89545] org.jivesoftware.smack.AbstractXMPPConnection.callConnectionClosedOnErrorListener() Connection XMPPBOSHConnection[swordfish@atalk.sytes.net/atalk] (0) closed with error
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.jivesoftware.smack.packet.XmlEnvironment.getEffectiveLanguage()' on a null object reference
        at org.jivesoftware.smack.util.ParserUtils.getXmlLang(ParserUtils.java:350)
        at org.jivesoftware.smack.util.PacketParserUtils.parseCommonStanzaAttributes(PacketParserUtils.java:134)
        at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.java:159)
        at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.java:114)
        at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:1330)
        at org.jivesoftware.smack.bosh.XMPPBOSHConnection.access$1600(XMPPBOSHConnection.java:68)
        at org.jivesoftware.smack.bosh.XMPPBOSHConnection$BOSHPacketReader.responseReceived(XMPPBOSHConnection.java:512)
        at org.igniterealtime.jbosh.BOSHClient.fireResponseReceived(BOSHClient.java:1609)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1144)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727)
        at java.lang.Thread.run(Thread.java:764)

It seems that currently there is also problem in error handling when there is an BOSHException

2019-10-19 10:03:58.769 23709-24548/org.atalk.android E/(AndroidOmemoService.java:123)#initializationFailed: OmemoManager init failed
    org.jivesoftware.smack.SmackException$NotConnectedException: The connection XMPPBOSHConnection[swordfish@atalk.sytes.net/atalk] (0) is no longer connected while waiting for response with IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=172IL-91)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (ignoreResourcepart): swordfish@atalk.sytes.net, FromMatchesFilter (full): atalk.sytes.net)) because of org.igniterealtime.jbosh.BOSHException: Could not parse body:
    <?xml version='1.0'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <h1>400 Bad Request</h1>
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:276)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:228)
        at org.jivesoftware.smackx.pubsub.LeafNode.publish(LeafNode.java:330)
        at org.jivesoftware.smackx.pubsub.LeafNode.publish(LeafNode.java:309)
        at org.jivesoftware.smackx.pubsub.PubSubManager.tryToPublishAndPossibleAutoCreate(PubSubManager.java:452)
        at org.jivesoftware.smackx.pep.PepManager.publish(PepManager.java:165)
        at org.jivesoftware.smackx.omemo.OmemoService.publishBundle(OmemoService.java:592)
        at org.jivesoftware.smackx.omemo.OmemoService.init(OmemoService.java:260)
        at org.jivesoftware.smackx.omemo.OmemoManager.initialize(OmemoManager.java:251)
        at org.jivesoftware.smackx.omemo.OmemoManager$2.run(OmemoManager.java:266)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: org.igniterealtime.jbosh.BOSHException: Could not parse body:
    <?xml version='1.0'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <h1>400 Bad Request</h1>
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:132)
        at org.igniterealtime.jbosh.StaticBody.fromString(StaticBody.java:114)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.awaitResponse(ApacheHTTPResponse.java:246)
        at org.igniterealtime.jbosh.ApacheHTTPResponse.getBody(ApacheHTTPResponse.java:192)
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1122)
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998)
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100)
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727)
        	... 1 more
     Caused by: java.lang.IllegalStateException: Root element was not 'body' in the 'http://jabber.org/protocol/httpbind' namespace.  (Was 'h1' in '')
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:98)
        at org.igniterealtime.jbosh.BodyParserXmlPull.parse(BodyParserXmlPull.java:132) 
        at org.igniterealtime.jbosh.StaticBody.fromString(StaticBody.java:114) 
        at org.igniterealtime.jbosh.ApacheHTTPResponse.awaitResponse(ApacheHTTPResponse.java:246) 
        at org.igniterealtime.jbosh.ApacheHTTPResponse.getBody(ApacheHTTPResponse.java:192) 
        at org.igniterealtime.jbosh.BOSHClient.processExchange(BOSHClient.java:1122) 
        at org.igniterealtime.jbosh.BOSHClient.processMessages(BOSHClient.java:998) 
        at org.igniterealtime.jbosh.BOSHClient.access$300(BOSHClient.java:100) 
        at org.igniterealtime.jbosh.BOSHClient$RequestProcessor.run(BOSHClient.java:1727)

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.