简体   繁体   中英

XMPP Server Connection Error

After successful login with XMPP Server getting error. Please Advice me. Thanks in advance.

Error : java.lang.IllegalArgumentException: servertime is not a constant in org.jivesoftware.smack.packet.Message$Type

D/SMACK﹕ RECV (0): <message from='sujewan@50.26.201.39/Smack' to='sujewan@50.26.201.39/Smack' type='servertime' timestamp='1439287908'/><presence from='sujewan@50.26.201.39/Smack' to='sujewan@50.26.201.39/Smack' xml:lang='en' id='I0TA4-8'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='NfJ3flI83zSdUDzCEICtbypursw='/></presence>

W/AbstractXMPPConnection﹕ Connection closed with error
        java.lang.IllegalArgumentException: servertime is not a constant in org.jivesoftware.smack.packet.Message$Type
                at java.lang.Enum.valueOf(Enum.java:200)
                at org.jivesoftware.smack.packet.Message$Type.valueOf(Message.java:607)
                at org.jivesoftware.smack.packet.Message$Type.fromString(Message.java:644)
                at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.java:229)
                at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.java:151)
                at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMPPConnection.java:947)
                at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$400(XMPPTCPConnection.java:139)
                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:982)
                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:937)
                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:952)
                at java.lang.Thread.run(Thread.java:818)

It seems like this happens when the client receives a <message/> stanza with a type attribute with the non-standard value servertime :

<message from='sujewan@50.26.201.39/Smack'
         to='sujewan@50.26.201.39/Smack'
         type='servertime'
         timestamp='1439287908'/>

Section 5.2.2 of RFC 6121 says:

If an application receives a message with no 'type' attribute or the application does not understand the value of the 'type' attribute provided, it MUST consider the message to be of type "normal" (ie, "normal" is the default).

So this is a bug in Smack: it shouldn't crash on non-standard type values. This should be reported to the Smack developers.


On the other hand, the servertime message is an unusual way of extending XMPP. The same RFC section says:

If included, the 'type' attribute MUST have one of the following values:

So setting type to servertime is not allowed. The usual way to add a new message type is to embed an XML element with a specific namespace, for example:

<message from='sujewan@50.26.201.39/Smack'
         to='sujewan@50.26.201.39/Smack'>
   <servertime xmlns='servertime' timestamp='1439287908'/>
</message>

(Ideally, for xmlns='servertime' put an HTTP URL that you control.)


On the third hand, for communicating time information, you might find that XEP-0202: Entity Time meets your needs. Support for XEP-0202 was added to Smack in version 3.4.1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM