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.


#6

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


#7

i create IM room but the room, i set IM room is persistent:

        /**XMPP会议室设置MUC*/
        // 获得聊天室的配置表单 根据原始表单创建一个要提交的新表单。
        Form form = muc.getConfigurationForm();
        Form answerForm = form.createAnswerForm();

        for(FormField formField:form.getFields()){
//            System.out.println(
//                    "TYPE(类型):"+formField.getType()+ ",Variable(参数):"+formField.getVariable());
            if(formField.getVariable() != null && !formField.getVariable().equals("FORM_TYPE")){
                System.out.println(formField.getVariable());
                answerForm.setDefaultAnswer(formField.getVariable());
            }
        }

        //房间名称
        answerForm.setAnswer("muc#roomconfig_roomname",roomname);
        //房间描述
        answerForm.setAnswer("muc#roomconfig_roomname","家庭圈");
        //房间是持久的
        answerForm.setAnswer("muc#roomconfig_persistentroom", true);
        //房间拥有者
        answerForm.setAnswer("muc#roomconfig_roomowners", owners);

        // 发送已完成的表单(有默认值)到服务器来配置聊天室
        muc.sendConfigurationForm(form);

the room is create success ,but the room persistent is fail ,
so i look code send message
the xml muc#roomconfig_persistentroom value is 0


i dont now why ? i setAnswer is true why have value is 0