powered by Jive Software

Server return error on getting History messages when Android phone has Arabic locate

Hello.
I am getting an error from the server when trying to get History message.
Environment:
Client: Android application(ATTENTION: With Arabic locate)
SMACK version: 4.3.4
Server ejabberd

Exception

Caused by: org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from user_85@conference.jawbonehealth.com: XMPPError: bad-request - modify [Bad value of field 'start' of type 'urn:xmpp:mam:1']
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:268)
        at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:219)
        at org.jivesoftware.smackx.mam.MamManager.queryArchivePage(MamManager.java:917)
        at org.jivesoftware.smackx.mam.MamManager.queryArchive(MamManager.java:900)
        at org.jivesoftware.smackx.mam.MamManager.queryArchive(MamManager.java:655)
        at com.a.b.c.d.e.lambda$null$6$e(e.java:229)
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:246) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 

Request Stanza

SMACK >>> SENT (0): 
    <iq to="user_85@conference.example.com" id="z48qV-32" type="set">
      <query xmlns="urn:xmpp:mam:1" queryid="7d889a60-277f-4c2a-afdb-88ef5edf4782">
        <x xmlns="jabber:x:data" type="submit">
          <field var="FORM_TYPE" type="hidden">
            <value>urn:xmpp:mam:1</value>
          </field>
          <field var="start">
            <value>٢٠٢١-١٠-١٢T١٦:٥١:٣٩.٢٢٢+00:00</value>
          </field>
          <field var="end">
            <value>٢٠٢١-١٠-١٣T٢٢:٣٥:٠٥.٩٨٨+00:00</value>
          </field>
        </x>
        <set xmlns="http://jabber.org/protocol/rsm">
          <max>100</max>
        </set>
      </query>
    </iq>

Response stanza

SMACK >>> RECV (0): 
    <iq xml:lang="en" to="user_85@example.com/android" from="user_85@conference.example.com" type="error" id="z48qV-32">
      <query xmlns="urn:xmpp:mam:1" queryid="7d889a60-277f-4c2a-afdb-88ef5edf4782">
        <set xmlns="http://jabber.org/protocol/rsm">
          <max>100</max>
        </set>
        <x xmlns="jabber:x:data" type="submit">
          <field var="FORM_TYPE" type="hidden">
            <value>urn:xmpp:mam:1</value>
          </field>
          <field var="start">
            <value>٢٠٢١-١٠-١٢T١٦:٥١:٣٩.٢٢٢+00:00</value>
          </field>
          <field var="end">
            <value>٢٠٢١-١٠-١٣T٢٢:٣٥:٠٥.٩٨٨+00:00</value>
          </field>
        </x>
      </query>
      <error code="400" type="modify">
        <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
        <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">Bad value of field 'start' of type 'urn:xmpp:mam:1'</text>
      </error>
    </iq>

code

                MamManager.MamQueryArgs.Builder builder = MamManager.MamQueryArgs.builder()
                        .setResultPageSizeTo(count);
                        
                if(fromTimestamp != null){
                    builder.limitResultsSince(fromTimestamp);
                } else {
                    builder.queryLastPage();
                }
                
                if (toTimestamp != null){
                    builder.limitResultsBefore(toTimestamp);
                }
                MamManager.MamQuery mamQuery = mamManager.queryArchive(builder.build());

So, the problem is next: MamQueryArgsBuilder converting Date() to String by using SimpleDateFormat.class with default Locate(in my case this is Arabic locate) and instead of converting the date like this: “2021-10-13T22:33:56.493+00:00” SMACK library convert it like this “٢٠٢١-١٠-١٣T٢٢:٣٥:٠٥.٩٨٨+00:00” and server cannot recognize values for “start” and “end” fields and sends back error_code =400 with next explanation “Bad value of field ‘start’ of type”.

Thanks for the report. That is indeed an issue within jxmpp. I have created

Thanks for the quick response.