Smack4.1.7 在回复超时内没有收到回复

Posted

技术标签:

【中文标题】Smack4.1.7 在回复超时内没有收到回复【英文标题】:Smack4.1.7 No response received within reply timeout 【发布时间】:2016-09-05 16:45:35 【问题描述】:

我在 android 上使用 smack 4.1.7 作为我的 xmpp 库,并在我的服务器上使用 openfire。设备从飞行模式上线后,当我尝试强制重新连接时出现异常。在正常的工作流程中,我没有得到这个异常。我希望我的应用程序支持离线模式,因此我必须确保从离线模式平稳过渡到在线模式。我使用飞行模式来测试这个场景。

我正在使用重新连接管理器以 20 秒的固定延迟处理重新连接。我强制重新连接,因为如果用户已经在应用程序中,我不希望用户等待 20 秒重新连接 xmpp。这就是为什么我仅在应用程序处于后台时才依靠重新连接管理器重新连接的原因。我希望这有助于理解我在这里尝试做什么。

我正在发布在 android 上启用 Smack 调试模式的堆栈跟踪:

07-26 13:55:45.154 com.myapp.xmpptest I/XmppService: Network state changed. Network connected.
07-26 13:55:45.154 com.myapp.xmpptest I/XmppService: Before xmppConnection connect.....
07-26 13:55:45.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 14

07-26 13:55:45.324 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='myapp.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='eaf60f002867230766bb74b4419dffca@myapp.com' xml:lang='en'>

07-26 13:55:45.404 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="myapp.com" id="bde2ec9" xml:lang="en" version="1.0">

07-26 13:55:45.484 com.myapp.xmpptest D/SMACK: RECV (0): <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanis ms></stream:features>

07-26 13:55:45.484 com.myapp.xmpptest D/SMACK: SENT (0): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>
07-26 13:55:45.564 com.myapp.xmpptest D/SMACK: RECV (0): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>
07-26 13:55:46.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 13

07-26 13:55:46.194 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='myapp.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='eaf60f002867230766bb74b4419dffca@myapp.com' xml:lang='en'>

07-26 13:55:46.274 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="myapp.com" id="bde2ec9" xml:lang="en" version="1.0"><stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanis ms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/></stream:features>

07-26 13:55:46.284 com.myapp.xmpptest D/xmppTest: XmppConnectionListener connectionConnected()
07-26 13:55:46.284 com.myapp.xmpptest D/SMACK: XMPPConnection connected (0)

07-26 13:55:46.284 com.myapp.xmpptest D/SMACK: SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>HJKSHGFJHJGKHDJHGJEHJKRHGJKFDHGhjshjkghruiehskrjgbjkeh5j4568o gjkfhdsgh589wwghjfdghsuHJKSHFIREHGHRUEIghgfhjdgsu87489YUFSfh483fhj==</auth>

07-26 13:55:47.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 12
07-26 13:55:47.174 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 0

07-26 13:55:51.293 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: No filter used or filter was 'null'.

07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java: 250)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginNonAnonymously(XMPPTCPConnect ion.java:374)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :456)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :414)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection. java:863)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.ja va:364)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at com.myapp.xmpp.XmppService.connectAndAuthenticate(XmppService.java:492)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at com.myapp.xmpp.XmppService$2.run(XmppService.java:195)
07-26 13:55:51.293 com.myapp.xmpptest W/System.err:     at java.lang.Thread.run(Thread.java:818)
07-26 13:55:51.293 com.myapp.xmpptest I/XmppService: Before xmppConnection login.....

07-26 13:55:51.293 com.myapp.xmpptest W/AbstractXMPPConnection: Connection closed with error
                                                                            javax.net.ssl.SSLException: Read error: ssl=0x9abd4400: I/O error during system call, Connection timed out
                                                                                at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
                                                                                at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketIm pl.java:753)
                                                                                at java.io.InputStreamReader.read(InputStreamReader.java:231)
                                                                                at java.io.BufferedReader.read(BufferedReader.java:325)
                                                                                at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)
                                                                                at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)
                                                                                at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)
                                                                                at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)
                                                                                at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
                                                                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1173)
                                                                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:952)
                                                                                at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:967)
                                                                                at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.293 com.myapp.xmpptest D/xmppTest: XmppConnectionListener connectionClosedOnError()
07-26 13:55:51.293 com.myapp.xmpptest W/System.err: javax.net.ssl.SSLException: Read error: ssl=0x9abd4400: I/O error during system call, Connection timed out
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketIm pl.java:753)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.io.InputStreamReader.read(InputStreamReader.java:231)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.io.BufferedReader.read(BufferedReader.java:325)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1173)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:952)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:967)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.303 com.myapp.xmpptest D/SMACK: XMPPConnection closed due to an exception (0)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err: javax.net.ssl.SSLException: Read error: ssl=0x9abd4400: I/O error during system call, Connection timed out
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketIm pl.java:753)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.io.InputStreamReader.read(InputStreamReader.java:231)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.io.BufferedReader.read(BufferedReader.java:325)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:1173)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPCon nection.java:952)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:967)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected.
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1248)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:345)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :451)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :414)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:248)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.lang.Thread.run(Thread.java:818)
07-26 13:55:51.303 com.myapp.xmpptest D/xmppTest: XmppConnectionListener reconnectionFailed()
07-26 13:55:51.303 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected.
07-26 13:55:51.303 com.myapp.xmpptest D/SMACK: Reconnection failed due to an exception (0)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1248)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err: at org.jivesoftware.smack.SmackException$NotConnectedException: Client is not, or no longer, connected.
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.throwNotConnectedExce ptionIfDoneAndResumptionNotPossible(XMPPTCPConnection.java:1248)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:345)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :451)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :414)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.ReconnectionManager$2.run(ReconnectionManager.java:248)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.lang.Thread.run(Thread.java:818)

07-26 13:55:51.303 com.myapp.xmpptest W/System.err: org.jivesoftware.smack.tcp.XMPPTCPConnection.throwNotConnectedExceptionIfApprop riate(XMPPTCPConnection.java:345)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java :451)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at com.myapp.xmpp.XmppService.connectAndAuthenticate(XmppService.java:538)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at com.myapp.xmpp.XmppService$2.run(XmppService.java:195)
07-26 13:55:51.303 com.myapp.xmpptest W/System.err:     at java.lang.Thread.run(Thread.java:818)
 
07-26 13:55:52.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 19
07-26 13:55:53.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 18
07-26 13:55:54.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 17
07-26 13:55:55.303 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 16
07-26 13:55:56.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 15
07-26 13:55:57.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 14
07-26 13:55:58.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 13
07-26 13:55:59.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 12
07-26 13:56:00.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 11
07-26 13:56:01.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 10
07-26 13:56:02.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 9
07-26 13:56:03.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 8
07-26 13:56:04.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 7
07-26 13:56:05.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 6
07-26 13:56:06.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 5
07-26 13:56:07.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 4
07-26 13:56:08.323 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 3
07-26 13:56:09.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 2
07-26 13:56:10.313 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 1
07-26 13:56:11.323 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 0
07-26 13:56:11.323 com.myapp.xmpptest D/SMACK: XMPPConnection (0) will reconnect in 0
 
07-26 13:56:11.373 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='myapp.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='eaf60f002867230766bb74b4419dffca@myapp.com' xml:lang='en'>

07-26 13:56:11.403 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="myapp.com" id="8dbb465e" xml:lang="en" version="1.0">

07-26 13:56:11.433 com.myapp.xmpptest D/SMACK: RECV (0): <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanis ms></stream:features>

07-26 13:56:11.443 com.myapp.xmpptest D/SMACK: SENT (0): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>
07-26 13:56:11.473 com.myapp.xmpptest D/SMACK: RECV (0): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>

07-26 13:56:11.963 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='myapp.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='eaf60f002867230766bb74b4419dffca@myapp.com' xml:lang='en'>

07-26 13:56:12.003 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="myapp.com" id="8dbb465e" xml:lang="en" version="1.0"><stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanis ms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/></stream:features>

07-26 13:56:12.003 com.myapp.xmpptest D/xmppTest: XmppConnectionListener connectionConnected()
07-26 13:56:12.003 com.myapp.xmpptest D/SMACK: XMPPConnection connected (0)

07-26 13:56:12.003 com.myapp.xmpptest D/SMACK: SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>HJKSHGFJHJGKHDJHGJEHJKRHGJKFDHGhjshjkghruiehskrjgbjkeh5j4568o gjkfhdsgh589wwghjfdghsuHJKSHFIREHGHRUEIghgfhjdgsu87489YUFSfh483fhj==</auth>

07-26 13:56:12.223 com.myapp.xmpptest D/SMACK: RECV (0): <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>

07-26 13:56:12.223 com.myapp.xmpptest D/SMACK: SENT (0): <stream:stream xmlns='jabber:client' to='myapp.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='eaf60f002867230766bb74b4419dffca@myapp.com' id='8dbb465e' xml:lang='en'>

07-26 13:56:12.253 com.myapp.xmpptest D/SMACK: RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="myapp.com" id="8dbb465e" xml:lang="en" version="1.0"><stream:features><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></stream:features>

07-26 13:56:12.253 com.myapp.xmpptest D/SMACK: SENT (0): <iq id='H0v5c-22' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>d73d639de6435579</resource>< /bind></iq>

07-26 13:56:12.283 com.myapp.xmpptest D/SMACK: RECV (0): <iq type="result" id="H0v5c-22" to="myapp.com/8dbb465e"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>eaf60f002867230766bb74b4419dffca@myapp.com/d73d639de6435579</jid></bind></iq>

07-26 13:56:12.293 com.myapp.xmpptest D/SMACK: SENT (0): <iq id='H0v5c-24' type='set'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>
07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: RECV (0): <iq type="result" id="H0v5c-24" to="eaf60f002867230766bb74b4419dffca@myapp.com/d73d639de6435579"/>
07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: User logged (0):eaf60f002867230766bb74b4419dffca@myapp.com:5222/d73d639de6435579
07-26 13:56:12.323 com.myapp.xmpptest D/xmppTest: XmppConnectionListener authenticated(). resumed : false
07-26 13:56:12.323 com.myapp.xmpptest D/xmppTest: joining control room
07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: XMPPConnection authenticated (0)
07-26 13:56:12.323 com.myapp.xmpptest D/xmppTest: XmppConnectionListener reconnectionSuccessful()

07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: SENT (0): <presence id='H0v5c-26'><c xmlns='http://jabber.org/protocol/caps' hash='sha-1' node='http://www.igniterealtime.org/projects/smack' ver='zIfK69gJkJ5OCxMILmZOsZ9HBlU='/></presence>
07-26 13:56:12.323 com.myapp.xmpptest D/SMACK: SENT (0): <presenceto='controlroom@conference.myapp.com/eaf60f002867230766bb74b4419dffca@myapp.com' id='H0v5c-27' type='unavailable'></presence>

如果我从日志中理解正确,当设备从飞行模式连接到互联网时,我尝试在网络更改事件中立即重新连接时会出现异常。但是,它最终会通过重新连接管理器进行连接。我用来触发 xmpp 连接和登录的代码如下:

// The network monitor

    private BroadcastReceiver networkMonitor = new BroadcastReceiver() 
        @Override
        public void onReceive(Context context, Intent intent) 
            if (isOnline && !Utilities.isOnline(AbstractActivity.this)) 
                isOnline = false;
             else if (!isOnline && Utilities.isOnline(AbstractActivity.this)) 
                // Trigger only when going from offline to online
                isOnline = Utilities.isOnline(AbstractActivity.this);

                // Re-establish the xmpp connection if it was disconnected
                if (isOnline ) 
                    connectAndAuthenticate();
                
            
        
    ;

    public void connectAndAuthenticate() 
        if(xmppConnection==null)
        XMPPTCPConnectionConfiguration.Builder builder = XMPPTCPConnectionConfiguration.builder()
                                                                                        .setUsernameAndPassword(hashedUserName, getPassword())
                                                                                        .setServiceName(serviceName)
                                                                                        .setHost(getCoreServer())
                                                                                        .setSendPresence(true)
                                                                                        .setSecurityMode(ConnectionConfiguration.SecurityMode.required)
                                                                                        .setPort(Integer.parseInt(port))
                                                                                        .setResource(getDeviceID());
          if (BuildConfig.DEBUG) 
            builder.setDebuggerEnabled(true);
          

          XMPPTCPConnectionConfiguration config = builder.build();

          xmppConnection = new MVXMPPTCPConnection(config);

          // Disable the roster
          Roster.getInstanceFor(xmppConnection).setRosterLoadedAtLogin(false);

          ReconnectionManager reconnectionManager = ReconnectionManager.getInstanceFor(xmppConnection);
          reconnectionManager.enableAutomaticReconnection();
          reconnectionManager.setReconnectionPolicy(ReconnectionManager.ReconnectionPolic y.FIXED_DELAY);
          reconnectionManager.setFixedDelay(20);

          PingManager pingManager = PingManager.getInstanceFor(xmppConnection);
          pingManager.registerPingFailedListener(this);
          pingManager.setPingInterval(60);

          // Instantiates a ChatStateManager.
          ChatStateManager.getInstance(xmppConnection);
  

        // connect
        try 
            Log.i(TAG, "Before xmppConnection connect.....");
            xmppConnection.connect();
            Log.i(TAG, "After xmppConnection connect.....");
         catch (SmackException.AlreadyConnectedException e) 
            e.printStackTrace();
         catch (SmackException e) 
            e.printStackTrace();
         catch (IOException e) 
            e.printStackTrace();
         catch (XMPPException e) 
            e.printStackTrace();
         catch (Exception e) 
            e.printStackTrace();
        


        // login
        try 
            Log.i(TAG, "Before xmppConnection login.....");
            xmppConnection.login(hashedUserName, getPassword(), getDeviceID());
            Log.i(TAG, "After xmppConnection login.....");
            // return
         catch (SmackException.AlreadyLoggedInException e) 
            e.printStackTrace();
         catch (SmackException.ConnectionException e) 
            e.printStackTrace();
         catch (XMPPException e) 
            e.printStackTrace();
         catch (Exception e) 
            e.printStackTrace();
        
    

我收到了很多这样的错误。任何人都可以在这里帮助我。我在谷歌上搜索了很多,几乎没有任何结果。我还在 Smack 支持社区发布了这个问题,但还没有收到任何人的回复。

PS:我已经用尽了我可以在正文部分添加的行数,所以我发布了 openfire 服务器日志作为答案,因为我不知道如何以正确的格式包含所有内容,而不会像这样破坏它们。对此我深表歉意。

【问题讨论】:

既然您使用了重新连接管理器,为什么您在连接更改时显式登录?重新连接管理器不会处理吗? 重新连接管理器将每 20 秒进行一次重新连接尝试。当用户在应用程序中时,我不希望用户等待 20 秒直到应用程序上线,所以我在收到 Internet 连接已建立的通知后立即尝试连接。我主要依靠重新连接管理器在应用程序处于后台时重新连接。谢谢。 【参考方案1】:

当您为移动客户端提供服务时,服务器端异常在生产日志中非常常见。这清楚地表明,在移动设备上,我们的网络不断切换,这与不经常连接/断开连接的桌面 LAN/WiFi 连接不同。

所以你的特殊情况似乎是一个,你可以通过我相信你已经在做的重新连接策略来控制它。

【讨论】:

非常感谢您的回复。我以为没有人会在这里帮助我:)您的回答确实消除了对服务器端日志的一些疑问,但我仍然不明白是什么导致了超时异常“在回复超时内没有收到响应。超时为 5000 毫秒( ~5s)。使用的过滤器:未使用过滤器或过滤器为“空”。”在客户端。我在上面的服务器日志之后添加最新的客户端日志。如果您能在这里帮助我,我将不胜感激。谢谢。 您是否正在检查设备是否正确连接到 wifi 或数据。使用连接管理器(如果连接或未连接)? 是的,我尝试从 networkMonitor 进行连接,该 networkMonitor 监视网络连接并侦听 android.net.conn.CONNECTIVITY_CHANGE,并且如上面代码中所定义。我应该检查其他东西吗?谢谢【参考方案2】:

来自 openfire 服务器的日志:

2016.08.24 07:24:30 org.jivesoftware.openfire.nio.ConnectionHandler - ConnectionHandler reports IOException for session: (SOCKET, R: /70.198.72.125:5004, L: /172.16.23.40:5222, S: 0.0.0.0/0.0.0.0:5222)
javax.net.ssl.SSLHandshakeException: SSL handshake failed.
at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:416)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)
at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived (AbstractIoFilterChain.java:499)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(Abstra ctIoFilterChain.java:293)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.j ava:228)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcesso r.java:198)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProce ssor.java:45)
at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProce ssor.java:485)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(Unknown Source)
at sun.security.ssl.SSLEngineImpl.readNetRecord(Unknown Source)
at sun.security.ssl.SSLEngineImpl.unwrap(Unknown Source)
at javax.net.ssl.SSLEngine.unwrap(Unknown Source)
at org.apache.mina.filter.support.SSLHandler.unwrap0(SSLHandler.java:668)
at org.apache.mina.filter.support.SSLHandler.unwrapHandshake(SSLHandler.java:624)
at org.apache.mina.filter.support.SSLHandler.handshake(SSLHandler.java:503)
at org.apache.mina.filter.support.SSLHandler.messageReceived(SSLHandler.java:306)
at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:392)
... 14 more
2016.08.24 07:24:56 org.jivesoftware.openfire.nio.ConnectionHandler - ConnectionHandler reports IOException for session: (SOCKET, R: /70.198.72.125:5016, L: /172.16.23.40:5222, S: 0.0.0.0/0.0.0.0:5222)
javax.net.ssl.SSLHandshakeException: SSL handshake failed.
at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:416)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.access$1100(AbstractIoFilt erChain.java:53)
at org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceive d(AbstractIoFilterChain.java:648)
at org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived (AbstractIoFilterChain.java:499)
at org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(Ab stractIoFilterChain.java:299)
at org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(Abstra ctIoFilterChain.java:293)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.j ava:228)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcesso r.java:198)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProce ssor.java:45)
at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProce ssor.java:485)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLException: Unsupported record version Unknown-97.117
at sun.security.ssl.InputRecord.checkRecordVersion(Unknown Source)
at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(Unknown Source)
at sun.security.ssl.SSLEngineImpl.readNetRecord(Unknown Source)
at sun.security.ssl.SSLEngineImpl.unwrap(Unknown Source)
at javax.net.ssl.SSLEngine.unwrap(Unknown Source)
at org.apache.mina.filter.support.SSLHandler.unwrap0(SSLHandler.java:668)
at org.apache.mina.filter.support.SSLHandler.unwrapHandshake(SSLHandler.java:624)
at org.apache.mina.filter.support.SSLHandler.handshake(SSLHandler.java:503)
at org.apache.mina.filter.support.SSLHandler.messageReceived(SSLHandler.java:306)
at org.apache.mina.filter.SSLFilter.messageReceived(SSLFilter.java:392)
... 14 more

如果我需要更多信息,请告诉我。

更新: 这里还有一些客户端日志,可能会提供更多信息。

09-14 02:09:07.130 10994 12986 D SMACK   : SENT (0): <iq to='controlroom@conference.myapp.com' id='JQYId-1396' type='get'><query xmlns='http://jabber.org/protocol/muc#owner'></query></iq>
09-14 02:09:07.230 10994 12987 D SMACK   : RECV (0): <iq type="error" id="JQYId-1396" from="controlroom@conference.myapp.com" to="eaf60f002867230766bb74b4419dffca@myapp.com/d73d639de6435579"><query xmlns="http://jabber.org/protocol/muc#owner"/><error code="403" type="auth"><forbidden xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>

09-14 02:09:07.250 10994 11433 D SMACK   : XMPPConnection reconnected (0)

09-14 02:09:08.960 10994 10994 W ResourcesManager: getTopLevelResources: /data/app/com.myapp.xmpptest-1/base.apk / 1.0 running in com.myapp.xmpptest rsrc of package null
09-14 02:09:09.180 10994 10994 D myapp   : getApplicationPackage : com.myapp.xmpptest
09-14 02:09:09.210 10994 10994 I XmppService: UserName from preferences : harit.mehta1@hotmail.com

09-14 02:09:09.220 10994 13097 I XmppService: Before xmppConnection connect.....
09-14 02:09:09.220 10994 13097 I XmppService: Before xmppConnection login.....

09-14 02:09:10.560 10994 10994 I Choreographer: Skipped 74 frames!  The application may be doing too much work on its main thread.
09-14 02:09:11.070 10994 10994 I Timeline: Timeline: Activity_idle id: android.os.BinderProxy@a12e696 time:5117900
09-14 02:09:28.900 10994 10994 V ActivityThread: updateVisibility : ActivityRecordfe7fff6 token=android.os.BinderProxy@a12e696 com.myapp.xmpptest/com.myapp.xmpptest.DashFragmentActivity show : false

09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection: Connection closed with error
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection: javax.net.ssl.SSLException: Read error: ssl=0x9bf6cd80: I/O error during system call, Connection timed out
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:811)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at java.io.InputStreamReader.read(InputStreamReader.java:233)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at java.io.BufferedReader.read(BufferedReader.java:325)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1173)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
09-14 02:09:46.200 10994 12987 W AbstractXMPPConnection:    at java.lang.Thread.run(Thread.java:818)

09-14 02:09:46.200 10994 12987 D myapp   : XmppConnectionListener connectionClosedOnError()

09-14 02:09:46.200 10994 12987 W System.err: javax.net.ssl.SSLException: Read error: ssl=0x9bf6cd80: I/O error during system call, Connection timed out
09-14 02:09:46.200 10994 12987 W System.err:    at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
09-14 02:09:46.200 10994 12987 W System.err:    at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:811)
09-14 02:09:46.200 10994 12987 W System.err:    at java.io.InputStreamReader.read(InputStreamReader.java:233)
09-14 02:09:46.200 10994 12987 W System.err:    at java.io.BufferedReader.read(BufferedReader.java:325)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1173)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
09-14 02:09:46.200 10994 12987 W System.err:    at java.lang.Thread.run(Thread.java:818)

09-14 02:09:46.200 10994 12987 D SMACK   : XMPPConnection closed due to an exception (0)

09-14 02:09:46.200 10994 12987 W System.err: javax.net.ssl.SSLException: Read error: ssl=0x9bf6cd80: I/O error during system call, Connection timed out
09-14 02:09:46.200 10994 12987 W System.err:    at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
09-14 02:09:46.200 10994 12987 W System.err:    at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:811)
09-14 02:09:46.200 10994 12987 W System.err:    at java.io.InputStreamReader.read(InputStreamReader.java:233)
09-14 02:09:46.200 10994 12987 W System.err:    at java.io.BufferedReader.read(BufferedReader.java:325)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.util.ObservableReader.read(ObservableReader.java:41)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.fillBuffer(KXmlParser.java:1515)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.peekType(KXmlParser.java:992)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.next(KXmlParser.java:349)
09-14 02:09:46.200 10994 12987 W System.err:    at org.kxml2.io.KXmlParser.next(KXmlParser.java:313)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1173)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:952)
09-14 02:09:46.200 10994 12987 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:967)
09-14 02:09:46.200 10994 12987 W System.err:    at java.lang.Thread.run(Thread.java:818)

09-14 02:09:47.320 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 19
09-14 02:09:48.360 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 18
09-14 02:09:49.400 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 17

09-14 02:09:50.170 10994 10994 W ResourcesManager: getTopLevelResources: /data/app/com.myapp.xmpptest-1/base.apk / 1.0 running in com.myapp.xmpptest rsrc of package null
09-14 02:09:50.400 10994 10994 D myapp   : getApplicationPackage : com.myapp.xmpptest
09-14 02:09:50.430 10994 10994 I XmppService: UserName from preferences : harit.mehta1@hotmail.com

09-14 02:09:50.440 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 16
09-14 02:09:50.440 10994 14662 I XmppService: Before xmppConnection connect.....
09-14 02:09:51.440 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 15
09-14 02:09:52.440 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 14
09-14 02:09:52.460 10994 10994 I Choreographer: Skipped 115 frames!  The application may be doing too much work on its main thread.
09-14 02:09:53.440 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 13

09-14 02:09:53.500 10994 10994 I Timeline: Timeline: Activity_idle id: android.os.BinderProxy@a12e696 time:5160339

09-14 02:09:53.680 10994 14774 D SMACK   : SENT (0): <stream:stream xmlns='jabber:client' to='myapp.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='eaf60f002867230766bb74b4419dffca@myapp.com' xml:lang='en'>
09-14 02:09:53.740 10994 14775 D SMACK   : RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="myapp.com" id="b894b7e" xml:lang="en" version="1.0">
09-14 02:09:53.800 10994 14775 D SMACK   : RECV (0): <stream:features><starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanisms></stream:features>

09-14 02:09:53.800 10994 14774 D SMACK   : SENT (0): <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'></starttls>
09-14 02:09:53.870 10994 14775 D SMACK   : RECV (0): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>

09-14 02:09:54.250 10994 14774 D SMACK   : SENT (0): <stream:stream xmlns='jabber:client' to='myapp.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='eaf60f002867230766bb74b4419dffca@myapp.com' xml:lang='en'>
09-14 02:09:54.300 10994 14775 D SMACK   : RECV (0): <?xml version='1.0' encoding='UTF-8'?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="myapp.com" id="b894b7e" xml:lang="en" version="1.0"><stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>PLAIN</mechanism></mechanisms><compression xmlns="http://jabber.org/features/compress"><method>zlib</method></compression><auth xmlns="http://jabber.org/features/iq-auth"/></stream:features>

09-14 02:09:54.310 10994 14662 D myapp   : XmppConnectionListener connectionConnected()

09-14 02:09:54.310 10994 14662 D SMACK   : XMPPConnection connected (0)
09-14 02:09:54.330 10994 14774 D SMACK   : SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>lkdhfgkhfdltsyireghjHASHKhfhioqethrh275984758hgjksdhg894q39kHKHIG89Y5HDFJKGNJKSY4E893HKJFHDUYST4HJHWA7389J5KLHFH97jkj97uotigdkhgfd8976i3qkH9786OI45H6TJKHIA7OTI3I4WHTLIURFUIY9==</auth>

09-14 02:09:54.440 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 12
09-14 02:09:54.440 10994 14484 D SMACK   : XMPPConnection (0) will reconnect in 0

09-14 02:09:59.380 10994 14774 D SMACK   : SENT (0): <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>lkdhfgkhfdltsyireghjHASHKhfhioqethrh275984758hgjksdhg894q39kHKHIG89Y5HDFJKGNJKSY4E893HKJFHDUYST4HJHWA7389J5KLHFH97jkj97uotigdkhgfd8976i3qkH9786OI45H6TJKHIA7OTI3I4WHTLIURFUIY9==</auth>

09-14 02:09:59.380 10994 14662 W System.err: org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 5000ms (~5s). Used filter: No filter used or filter was 'null'.
09-14 02:09:59.390 10994 14662 W System.err:    at org.jivesoftware.smack.SASLAuthentication.authenticate(SASLAuthentication.java:250)
09-14 02:09:59.390 10994 14662 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection.loginNonAnonymously(XMPPTCPConnection.java:374)
09-14 02:09:59.390 10994 14662 W System.err:    at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:456)
09-14 02:09:59.390 10994 14662 W System.err:    at org.jivesoftware.smack.AbstractXMPPConnection.login(AbstractXMPPConnection.java:414)
09-14 02:09:59.390 10994 14662 W System.err:    at org.jivesoftware.smack.tcp.XMPPTCPConnection.connectInternal(XMPPTCPConnection.java:863)
09-14 02:09:59.390 10994 14662 W System.err:    at org.jivesoftware.smack.AbstractXMPPConnection.connect(AbstractXMPPConnection.java:364)
09-14 02:09:59.390 10994 14662 W System.err:    at com.myapp.xmpp.XmppService.connectAndAuthenticate(XmppService.java:591)
09-14 02:09:59.390 10994 14662 W System.err:    at com.myapp.xmpp.XmppService$2.run(XmppService.java:217)
09-14 02:09:59.390 10994 14662 W System.err:    at java.lang.Thread.run(Thread.java:818)
09-14 02:09:59.410 10994 14662 D Utilities: Xmpp Log Files directory created : true
09-14 02:09:59.800 10994 14662 D Utilities: ~~~~~~~~~~~~~~~~~~~Log file saved. returning~~~~~~~~~~~~~~
09-14 02:09:59.800 10994 14662 I XmppService: Before xmppConnection login.....

似乎客户端从未收到对“auth”节的响应。查看 smack 库中的代码后,我认为“XMPPTCPConnection.java”中的“connectInternal()”方法中的以下代码可能会导致此错误。我认为当连接方法仍在握手过程中时,会调用登录名,这可能会在服务器上搞砸。在我们调用登录之前是否应该有一些延迟,直到握手过程完成?如果是这样,我该如何解决这个问题?如果不是,那么可能导致超时错误的原因是什么?

谢谢。

【讨论】:

以上是关于Smack4.1.7 在回复超时内没有收到回复的主要内容,如果未能解决你的问题,请参考以下文章

TCP Retransmission重新传送超过5次后还没收到回复会怎么办?

寝室局域网内ping命令目标主机无法访问和请求超时怎么回事

微信超时5s,调用客服接口异步回复消息(PHP)

彩虹工人在超时后被杀死,即使它回复了

网络出现连接超时怎么解决?

PHP SoapClient 超时