我有xmpp serverside绑定与致命错误的问题

时间:2017-09-29 12:24:06

标签: xmpp ejabberd converse.js

我开始使用converse js,首先,我正在使用 converse.js 3.2.1 ,对于xmpp服务器,我正在使用 ejabberd 17.04 ,以及我想要的是:

  1. 登录converse js并获取jid值
  2. 在浏览器中保持会话活动(无论何时关闭或刷新)
  3. 添加一些可以销毁会话的注销

通过谷歌搜索和阅读文档这么多的努力,我得出的结论是,我必须使用keepalive,prebind,prebind url并提供jid,我必须添加服务器端预绑定,我发现这个xmpp library < / p>

但是当我尝试预绑定时,我遇到了一些错误:

  

致命错误:未捕获XmppPrebindConnectionException:在服务器响应中找不到子级。在/var/www/html/converse.js/bind/lib/XmppPrebind.php:170堆栈跟踪:#0 /var/www/html/converse.js/bind/bind.php(19):XmppPrebind-&gt;在第170行的/var/www/html/converse.js/bind/lib/XmppPrebind.php中连接('admin3 @ localhos ...','xxxxxx')#1 {main}

这是我的服务器端代码

$xmppPrebind = new XmppPrebind('localhost', 'http://localhost:5280/http-bind/', '5280', false, false);
$xmppPrebind->connect('admin3@localhost', 'xxxxx');
$xmppPrebind->auth();
$sessionInfo = $xmppPrebind->getSessionInfo(); // array containing sid, rid and jid
echo $sessionInfo;


    这是我的converse.init:

 converse.initialize({
            prebind: true,
            prebind_url: "bind/bind.php",
            allow_muc_invitations : true,
            allow_logout: true,
            jid : "admin3@localhost",
            debug: true,
            bosh_service_url: 'http://localhost:5280/http-bind/',
            keepalive : true,
            authentification: 'prebind',
            prebind : true,
            auto_list_rooms: true,
            auto_subscribe: false,
            hide_muc_server: false,
            i18n: locales.id, // Refer to ./locale/locales.js to see which locales are supported
            show_controlbox_by_default: true,
            xhr_user_search: false,
            play_sounds: true,
            sounds_path : "http://localhost/converse.js/sounds/",
            message_storage : 'local',
            message_archiving: 'always',
            default_domain : "localhost"
        });

1 个答案:

答案 0 :(得分:0)

在同一异常上停留了好几个小时,在大量挖掘之后,我用下面提到的库替换了Xmpp库,它对我来说就像是魅​​力。.

https://github.com/turalus/XMPP-Prebind-for-PHP

也用

代替相反的初始化。
 jid : "admin3"    //just username without hostname as your library will concatenate it for you
 bosh_service_url: 'http://localhost:5280/bosh/'    //the updated ejabberd bosh url

休息看起来不错。