I am trying to connect to the Jabber server of Jitsi using stanza.io.
But this seems more complex than I guess.
Reading the documentation Reference.md doesnot helps me to understand the problem.
So I extract a minimal example with getDiscoInfo that raise a timeout.
Using the following code in the stackoverflow snippet failed but fore another reason (access to window.localstorage fails).
<html>
<head>
<script src="https://rawgit.com/legastero/stanza.io-demo/gh-pages/stanzaio.bundle.js"></script>
<script>
function write(text) {
var textNode = document.createElement("li");
textNode.textContent = text;
document.body.appendChild(textNode);
}
var serverName = "meet.jit.si";
var userName = "user";
var roomName = "testroom";
var muc = "conference." + serverName;
var roomUrl = roomName + "@" + muc;
var client = XMPP.createClient({
jid: roomName + "@" + serverName,
boshURL: location.protocol+ "//" + serverName + "/http-bind",
transports: ['bosh']
});
client.connect();
client.getDiscoInfo(roomUrl,'', (err, data) => {
write("err:"+ JSON.stringify(err) + " data:" + JSON.stringify(data))
});
</script>
</head>
</html>
However this could run from this JSFiddle.
It fails with error :
err:{"id":"5d30db9b-b2f1-4915-b387-424cb6e1673a","type":"error","error":{"condition":"timeout"}} data:undefined
I tried with getTime and some others methods.
But some calls are working like
client.joinRoom(roomUrl, userName, {status:"available"});
As behavior is the same using a local jitsi instance and using the publicly available server meet.jit.si, I guess the problem is not in my installation.
Do you know why nearly all requests to the XMPP server fails ?
getDiscoItems method need to be called after session initialization.
I was able to get answer modifying the code like this :
client.on('session:started', () => {
client.getDiscoItems(muc,'', (err, data) => {
write("err:"+ JSON.stringify(err) + " data:" + JSON.stringify(data))
});
} )
It give the expected result :
err:null data:{"discoItems":{},"lang":"en","id":"cc3c40c8-0528-42d0-879c-fb67cf400b92","to":"ad2506f3-03ef-4c7c-b472-bc757070e570@meet.jit.si/2c52a03b-8eb1-4329-8dbe-de68a2c4f682","from":"conference.meet.jit.si","type":"result"}