0

i started to using converse js,first of all,i am using converse.js 3.2.1 and for the xmpp server i am using ejabberd 17.04,and what i want is:

  1. login to converse js and get the jid value
  2. keep session alive across the browser( whenever it's closed or refresh )
  3. Add some logout that can destroy the session

with so much effort on googling and read the documentation,i reached the conclusion that i must using keepalive,prebind,prebind url and provide the jid,and i must add serverside prebinding,and i found this xmpp library

but when i try the prebinding i got some kind of error :

Fatal error: Uncaught XmppPrebindConnectionException: Child not found in response from server. in /var/www/html/converse.js/bind/lib/XmppPrebind.php:170 Stack trace: #0 /var/www/html/converse.js/bind/bind.php(19): XmppPrebind->connect('admin3@localhos...', 'xxxxxx') #1 {main} thrown in /var/www/html/converse.js/bind/lib/XmppPrebind.php on line 170

this is my serverside code

$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;


and this is my 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 Answers1

0

Got stuck on the same exception for hours and after digging alot, i replaced the Xmpp library with the below mentioned library and it worked like charm for me..

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

Also replace the converse initialize with

 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

Rest looks fine.

Pankhur
  • 16
  • 1