Could Not Connect XMPP Server with smack : EOF Exception when implementing GCM XMPP-based App Server

痴心易碎 提交于 2019-12-22 09:54:38

问题


java.io.EOFException: no more data available - expected end tag </stream:stream> to close start tag <stream:stream> from line 1, parser stopped on END_TAG seen ...</mechanisms></stream:features>... @1:344
at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3035)
at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046)
at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1144)
at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:279)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)

//resources : https://developer.android.com/google/gcm/ccs.html#implement

I have tried the exact code which is given in the android website, but it is throwing the end of file exception which i am thinking as some bug in MXParser(not quite sure though). If smack XMPP library is the problem, Is there any other xmpp library which i can use for GCM CCS ? Could any one please help me fix this . In the below image you can see the end stream tag is not closed but this is how i am receiving the packets.

sent and received packets Output windows:


回答1:


For some reason, I have restarted the machine and it got fixed by itself




回答2:


One possible cause is described here:

You need to send some heartbeat - either at XMPP or TCP level - so your endpoint can detect (or prevent) the closed TCP. Many router/NATs fail to send RST or FIN, just drop the TCP connection.

For example, you may use PingManager (smack-extensions) to implement such a heartbeat.



来源:https://stackoverflow.com/questions/18318398/could-not-connect-xmpp-server-with-smack-eof-exception-when-implementing-gcm-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!