3

我尝试从一位 fb 用户向他的一位朋友发送消息。大多数情况下,消息都会收到。丢失的在日志中被标记为已发送。用于发送消息的 ruby​​ gem 是xmpp4r_facebook,它又使用xmpp4r。示例丢失的消息是Hi, friend! 2013-09-11 17:46:10 +0300未收到的消息:

Hi, friend! 2013-09-11 17:46:05 +0300
Hi, friend! 2013-09-11 17:46:08 +0300
Hi, friend! 2013-09-11 17:46:13 +0300
Hi, friend! 2013-09-11 17:46:16 +0300

以下是与成功接收消息的日志类似的消息日志:


Debugging mode enabled.
Warnings mode enabled.
RESOLVING:
    _xmpp-client._tcp.chat.facebook.com (SRV)
CONNECTING:
    chat.facebook.com:5222
"Socket:"
"local address: [\"AF_INET\", 39123, \"172.27.*.**\", \"172.27.*.**\"]"
"Thread list size: 1"
#<TCPSocket:fd 11>
SENDING:
    <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='chat.facebook.com' xml:lang='en' version='1.0' >
RECEIVED:
    <stream:stream from='chat.facebook.com' id='1' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xmlns='jabber:client'/>
RECEIVED:
    <stream:features><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
FEATURES: received
PROCESSING:
    <stream:features xmlns='jabber:client'><starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features> (REXML::Element)
FEATURES: waiting...
TRYING stanzacbs...
FEATURES: waiting finished
TRYING message/iq/presence/cbs...
SENDING:
    <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
RECEIVED:
    <proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
TLSv1: OpenSSL handshake in progress
TLSv1: restarting parser
"Socket:"
"local address: [\"AF_INET\", 39123, \"172.27.*.**\", \"172.27.*.**\"]"
"Thread list size: 1"
#<TCPSocket:fd 11>
SENDING:
    <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='chat.facebook.com' xml:lang='en' version='1.0' >
RECEIVED:
    <stream:stream from='chat.facebook.com' id='1' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xmlns='jabber:client'/>
RECEIVED:
    <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>
FEATURES: waiting...
FEATURES: received
PROCESSING:
    <stream:features xmlns='jabber:client'><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>X-FACEBOOK-PLATFORM</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features> (REXML::Element)
TRYING stanzacbs...
FEATURES: waiting finished
TRYING message/iq/presence/cbs...
SENDING:
    <auth mechanism='X-FACEBOOK-PLATFORM' xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
RECEIVED:
    <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>dmVyc2lvbj0x...</challenge>
SASL DIGEST-MD5 challenge:
    version=1&method=auth.xmpp_login&nonce=E547D1842...
    {"version"=>"1", "method"=>"auth.xmpp_login", "nonce"=>"E547D1842..."}
SENDING:
    <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>YXBpX2...
    </response>
RECEIVED:
    <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
"Socket:"
"local address: [\"AF_INET\", 39123, \"172.27.*.**\", \"172.27.*.**\"]"
"Thread list size: 2"
#<TCPSocket:fd 11>
SENDING:
    <stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='chat.facebook.com' xml:lang='en' version='1.0' >
RECEIVED:
    <stream:stream from='chat.facebook.com' id='1' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xmlns='jabber:client'/>
RECEIVED:
    <stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></stream:features>
FEATURES: received
PROCESSING:
    <stream:features xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></stream:features> (REXML::Element)
TRYING stanzacbs...
TRYING message/iq/presence/cbs...
SENDING:
    <iq id='1192' type='set' xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'/></iq>
RECEIVED:
    <iq from='chat.facebook.com' id='1192' type='result'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>-100006248070281@chat.facebook.com/oRbc4KeQ</jid></bind></iq>
SENDING:
    <iq id='2614' type='set' xmlns='jabber:client'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>
RECEIVED:
    <iq from='chat.facebook.com' id='2614' type='result'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>
SENDING:
    <message to='-1552527098@chat.facebook.com' xmlns='jabber:client'><body>    Hi, friend! 2013-09-11 17:46:10 +0300
    </body></message>
SENDING:
    </stream:stream>

问题出在哪里?它是 FB 错误、gem 错误还是其他什么?

4

1 回答 1

1

好吧,这听起来很疯狂……而且……

我遇到了这个问题(使用将聊天消息发送到收件人列表的代码)并在两天的大部分时间里将头撞在墙上,像 OP 一样挖掘 XMPP 流量。我还发现接收到的数据在成功和失败之间是不变的。FB 只是高兴地吞下它,没有提供任何东西。非常令人沮丧!

在我的耐心快到尽头,并即将决定我们必须完全重新设计该功能(放弃 FB 聊天)时,我尝试了一个暗中的镜头,它似乎奏效了。

我在对 Client#send 的调用之间引入了人为的延迟(1 秒)。

非常神秘,这似乎可以解决它。我需要对其进行更多测试,但到目前为止,100% 的消息都是在这种延迟下传递的。对于我刚刚提交的代码,我没有合理的论据,但它似乎正在工作。我要买它!

于 2014-06-06T06:08:09.553 回答