我正在尝试为xmpp openfire服务器获取SASL认证。我在curl中运行php脚本后。传递哈希值后,我确实从服务器获取成功数据包。 但随着我前进绑定auth服务器给我未经授权的错误 我从https://groups.google.com/forum/#!topic/strophe/Y2n2dQ5oSoU中得到了一些提示 请参阅下面的输出日志:
<body rid='16465' xmlns='http://jabber.org/ protocol/httpbind' to='iamnew.test' zml:lang='en' wait='60' hold='1' content='application/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>
<body xmlns="http://jabber.org/protocol/httpbind" xmlns:stream="http://etherx.jabber.org/streams" from="iamnew.test" authid="102b0b8b" sid="102b0b8b" secure="true" requests="2" inactivity="30" polling="5" wait="60" hold="1" ack="16465" maxpause="300" ver="1.6"><stream:features><mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><mechanism>DIGEST-MD5</mechanism><mechanism>JIVE-SHAREDSECRET</mechanism><mechanism>PLAIN</mechanism><mechanism>CRAM-MD5</mechanism></mechanisms><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></body>
<body rid='16466' xmlns='http://jabber.org/protocol/httpbind' sid='102b0b8b'><auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>dGVzdDJAbGV0c3RhbGsudGVzdAB0ZXN0MgB0ZXN0Mg== </auth></body>
<body xmlns='http://jabber.org/protocol/httpbind'><success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/></body>
这是当我接下来为绑定时我得到错误401未授权
<body rid='16467' xmlns='http://jabber.org/protocol/httpbind' sid='102b0b8b'><iq type='set' id='_bind_auth_2' xmlns='jabber:client'><bind xmlns='urn:ietf:params:xml:ns:xmpp- bind'/></iq></body>
<body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns="jabber:client" type="error" id="_bind_auth_2" to="letstalk.test/102b0b8b"><bind xmlns="urn:ietf:params:xml:ns:xmpp- bind"/><error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq></body>
<body rid='16468' xmlns='http://jabber.org/protocol/httpbind' sid='102b0b8b'><iq type='set'id='_session_auth_2' xmlns='jabber:client'><sessionxmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq></body><body xmlns='http://jabber.org/protocol/httpbind'><iq xmlns="jabber:client" type="error" id="_session_auth_2" to="letstalk.test/102b0b8b"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/><error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq></body>
答案 0 :(得分:0)
来自XMPP over BOSH规范:
收到&lt; success /&gt;因此,客户必须要求 连接管理器通过发送&#34;重新启动来重新启动流 请求&#34;
所以你的下一个包应该是这样的:
<body rid='1573741824'
sid='SomeSID'
to='example.com'
xml:lang='en'
xmpp:restart='true'
xmlns='http://jabber.org/protocol/httpbind'
xmlns:xmpp='urn:xmpp:xbosh'/>