powered by Jive Software

Smack 4.2.4 public static XMPPError.Builder parseError(XmlPullParser parser) in PacketParserUtils class has problem

smack

#1

Smack has problem in “Parses error sub-packets” with the following server IQ error stanza received from server.
I have applied below simple patches to temporary fix the problem. There are two issues with the code i.e.

  1. parser.getAttributeValue("", “type”) will return null
  2. Builder ‘condition’ cannot be null

Patches:

        // Parse the error header
        String errorType = parser.getAttributeValue("", "type");
        if (StringUtils.isNullOrEmpty(errorType))
            builder.setType(XMPPError.Type.CANCEL);
        else
            builder.setType(XMPPError.Type.fromString(errorType));
        builder.setCondition(XMPPError.Condition.service_unavailable);

        // builder.setType(XMPPError.Type.fromString(parser.getAttributeValue("", "type")));
        builder.setErrorGenerator(parser.getAttributeValue("", "by"));

Smack Log:

05-25 14:05:56.590 7806-8403/org.atalk.android D/SMACK: RECV (0): <iq xmlns="jabber:client" id="962Pu-65" type="error" from="test5@marketing3.office.kontent.cc" to="test5@marketing3.office.kontent.cc/atalk">
       <pubsub xmlns="http://jabber.org/protocol/pubsub">
          <publish node="eu.siacs.conversations.axolotl.bundles:2087096589">
             <item>
                <bundle xmlns="eu.siacs.conversations.axolotl">
                   <signedPreKeyPublic signedPreKeyId="1">Bdwd5ViSrjuFnfQbj14JabfKhSbTo46fIijeoVhepBkO</signedPreKeyPublic>
                   <signedPreKeySignature>Cxg5vZmycyl4n0igT72k4N/6avtuWpE9/H0yiMTVcevgY2/deY4C0eFK/sryqWLsEpPJHr2r8h6IM4DTAUF/Cg==</signedPreKeySignature>
                   <identityKey>BZfHxn0pbsjIWr89/OXhGyww14jQCBxH1M0hTnaIqsUq</identityKey>
                   <prekeys>
                      <preKeyPublic preKeyId="1">Beq1AhaMs/hC+dq+fC94XOdR88D86ulnHaJ+2v3CFS4Q</preKeyPublic>
....
                      <preKeyPublic preKeyId="100">Bc8BJoEYHYCvOQMtW1n8hE4JHvK4cXmXtqpF/RIAZag9</preKeyPublic>
                   </prekeys>
                </bundle>
             </item>
          </publish>
       </pubsub>
       <error code="503" />
    </iq>

#2

A patch is usually considered a delta (diff) to the previous version. That makes it easer for other people to see what suggest to change. Could you show us such a diff?


#3

Here is the patch. Please note that this patch is only for reference as I did not include the error code translator.

PacketParserUtil.patch (1.3 KB)


#4

As far as I can tell Smack does everything right here: The ‘type’ attribute of error is mandatory as per RFC 6120 § 8.3.2 (see https://tools.ietf.org/html/rfc6120#section-8.3.2). It appears the pubsub service implementation is violating the RFC. If so, we should fix that.


#5

Thank for the clarification. The user from Germany has indicated that their xmpp server is very old; seems like the implementation is following specifications XEP-0099: IQ Query Action Protocol.

Would appreciate if Smack would consider supporting this variation.
I have removed the patches and use ParsingExceptionCallback instead to handle the issue, so aTalk can continue hinged on the official smack library release.


#7

A post was split to a new topic: Can not create persistent rooms