【问题标题】:Node.js solution for XMPP BOSH prebinding to return SID and RIDXMPP BOSH 预绑定返回 SID 和 RID 的 Node.js 解决方案
【发布时间】:2014-10-05 03:51:33
【问题描述】:

我需要在服务器端验证 Openfire XMPP 会话,并将会话传递给 strophe.js。但是,我找不到有效的预绑定库。

我一直在与https://github.com/node-xmpp/node-xmpp-client 的维护者合作,但我们无法解决以下问题:

var XMPP = require('node-xmpp-client')


var prebind = new XMPP({
    jid: 'metalaureate@localhost',
    password: 'holonarchy',
    wait: 60,
    bosh: {
        url: 'http://localhost:7070/http-bind/',
        prebind: function(error, data) {
            if (error) throw new Error(error);
            console.log(data);
            return data
            /*
                data.sid
                data.rid
             */
        }
    }
})

prebind.on('online', function() { console.log('Connected') });

我使用 Wireshark 来验证正确的节被发送到我的 BOSH 端点,并且 Openfire 正在返回正确的响应,但模块从不返回回调。

发送:

接收:

<body xmlns="http://jabber.org/protocol/httpbind" xmlns:stream="http://etherx.jabber.org/streams" from="localhost" authid="8bdd62a3" sid="8bdd62a3" secure="true" requests="2" inactivity="30" polling="5" wait="10" hold="1" ack="1836153693" maxpause="300" ver="1.6">

有任何解决方法或知道可以进行预绑定的其他节点库吗?

【问题讨论】:

    标签: javascript node.js xmpp


    【解决方案1】:

    希望此链接对您有所帮助,请参考:https://github.com/node-xmpp/node-xmpp-client/issues/77

     var XMPP = require('node-xmpp-client');
        var prebind = new XMPP({
            jid: 'test@localhost',
            password: 'xxx',
            preferred: 'PLAIN',
            wait: 10,
            bosh: {
                url: 'http://localhost:5280/http-bind/',
                prebind: function (error, data) {
                    if (error) throw new Error(error);
                    data.jid = 'test@localhost';
                    console.log(data);
                    **return res.send(data);**
                }
            },
            reconnect: true
    
        });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-09
      • 2018-10-06
      • 1970-01-01
      • 2017-02-19
      • 1970-01-01
      • 2017-02-17
      相关资源
      最近更新 更多