amb

Stream Management can't handle unexpected input

Discussion created by amb on Nov 6, 2014
Latest reply on Nov 7, 2014 by Flow

Current stream management code does not handle unexpected input well. I have a server that is returning the message id as the "h" attribute on stream management ack requests, which results in the exception below and a complete shutdown of the XMPPConnection.

 

11-06 14:13:37.147 W/AbstractXMPPConnection﹕ Connection closed with error

    java.lang.NumberFormatException: Invalid long: "w49kv-15"

            at java.lang.Long.invalidLong(Long.java:124)

            at java.lang.Long.parse(Long.java:361)

            at java.lang.Long.parseLong(Long.java:352)

            at java.lang.Long.parseLong(Long.java:318)

            at java.lang.Long.valueOf(Long.java:476)

            at org.jivesoftware.smack.util.ParserUtils.getLongAttribute(ParserUtils.java:98)

            at org.jivesoftware.smack.tcp.sm.provider.ParseStreamManagement.ackAnswer(ParseStr eamManagement.java:82)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1187)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:970)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:989)

 

Seems like just ignoring the ack when encountering a parse failure would be better.

 

Incidentally, I don't think shutting down the XMPPConnection on an unexpected exception is desirable behavior either, but that's probably a discussion for another thread.

Outcomes