无法得到 smack 的回应
Posted
技术标签:
【中文标题】无法得到 smack 的回应【英文标题】:Not able to get response from smack 【发布时间】:2017-04-15 06:46:49 【问题描述】:我正在使用 smack 连接 ejabbard 服务器。
使用以下代码通过 smack 连接 ejabbard 服务器
val config=XMPPTCPConnectionConfiguration.builder()
.setXmppDomain(mDomainName)
.setUsernameAndPassword(mUsername,mPassword)
.setDebuggerEnabled(true)
mConnection= XMPPTCPConnection(config.build())
Log.v("Current status ",mConnection!!.isConnected().toString())
mConnection!!.connect()
但最终得到错误/警告:
4-15 12:09:22.626 2685-3195/com.example.itstym.kotlinchat I/DNSUtil: Could not resolve DNS SRV resource records for _xmpp-client._tcp.replica3377.cloudapp.net. Consider adding those.
04-15 12:09:23.033 2685-3208/com.example.itstym.kotlinchat D/SMACK: SENT (1): <stream:stream xmlns='jabber:client' to='replica3377.cloudapp.net' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' from='user2@replica3377.cloudapp.net' xml:lang='en'>
04-15 12:09:23.189 2685-3209/com.example.itstym.kotlinchat D/SMACK: RECV (1): <?xml version='1.0'?><stream:stream id='3002662766383892485' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' to='user2@replica3377.cloudapp.net' from='replica3377.cloudapp.net' xmlns='jabber:client'>
04-15 12:09:23.190 2685-3209/com.example.itstym.kotlinchat D/SMACK: RECV (1): <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>DIGEST-MD5</mechanism><mechanism>X-OAUTH2</mechanism><mechanism>SCRAM-SHA-1</mechanism></mechanisms></stream:features>
04-15 12:09:28.846 2685-2754/com.example.itstym.kotlinchat D/SMACK: RECV (0): <stream:error><connection-timeout xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></stream:stream>
大约 30 秒后,我收到另一个错误
04-15 12:09:28.853 2685-2754/com.example.itstym.kotlinchat W/AbstractXMPPConnection: Connection XMPPTCPConnection[not-authenticated] (0) closed with error
org.jivesoftware.smack.XMPPException$StreamErrorException: connection-timeout You can read more about the meaning of this stream error at http://xmpp.org/rfcs/rfc6120.html#streams-error-conditions
<stream:error><connection-timeout xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error>
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1046)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:980)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:996)
at java.lang.Thread.run(Thread.java:818)
但是当我签入时,ejabbard 服务器会话已为用户启动。同样使用 converse.js 我可以验证用户是否已登录。
所以我想我没有得到 smack 的回应。
【问题讨论】:
【参考方案1】:查看 SMACK 关于创建连接的文档,您错过了对 connection.login()
的调用,因此它会在 5 秒后超时。 (查看最后 2 条 RECV 消息之间的差异)
文档:https://download.igniterealtime.org/smack/docs/latest/documentation/connections.html
【讨论】:
如果我只发出连接请求,那么它也应该向我发送连接成功消息。顺便说一句,我也尝试调用 login() 方法。但得到了同样的回应。 @Kiskae 你能检查一下这个问题吗***.com/questions/43491831/…以上是关于无法得到 smack 的回应的主要内容,如果未能解决你的问题,请参考以下文章
Laravel/000webhost/邮递员。无法得到任何回应
启用 IQProvider 时,Smack 无法识别 type="result" 节