0
votes

I am trying to make real-time chat using HTML5, WebSockets, strophe-openfire.js library (https://code.google.com/p/openfire-websockets/source/browse/trunk/src/ofchat/js/strophejs/src/strophe-openfire.js) and Openfire server.
I use this code snippet to make connection:

function connectHandler(cond) {  
    log("connected");  
    connection.send($pres());  
}

var url = "ws://localhost:7070/ws";    
connectButton.onclick = function() {  
   var username = document.getElementById("username").value;  
   var password = document.getElementById("password").value;  
    var connection = new Openfire.Connection (url);  
   connection.connect(username, password,  connectHandler);  
}

I see on Openfire admin console in Client Sessions tab that user is "Authenticated" but is still Offline. On Chrome console I see response from Openfire with 101 Switching Protocols and appropriate headers but nothing more.

so my question is what can be the cause that connection.send($pres()) doesn't work and how to send presence to Openfire.

thanks in advance.
Andrew

1
CLOSED: found workaround in using openfire-websockets.js and peek.js library shipped with Openfire Websockets plugin. Sending presence through raw XML send.user2637788
can you tell me how did you install websocket plugin for openfire ?Hunt

1 Answers

0
votes

Sorry I can't help with an answer, but I am having the exact same problem. My Openfire server establishes the websocket connection, but never returns a response for:

<?xml version='1.0'?><stream:stream to='satellite-l675' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en' xmlns:xml="http://www.w3.org/XML/1998/namespace">

I am using Openfire 3.8.2 with the .0006 websocktet plugin. I am trying to use Candy chat as the client.

I did by accident get it to communicate with the Openfire websocket by bypassing authentication and sending this:

Sent: <stream:stream to='satellite-l675' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'/>

Sent: <presence xmlns='jabber:client'/>

Sent: <iq type='get' from='@satellite-l675/Candy' to='[email protected]' id='disco3' xmlns='jabber:client'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq>

Sent: <presence from='satellite-l675/Candy' to='[email protected]/yogi' xmlns='jabber:client'> <x xmlns='http://jabber.org/protocol/muc'/> </presence>

Sent: <iq type='get' from='@satellite-l675/Candy' id='get1' xmlns='jabber:client'> <query xmlns='jabber:iq:privacy'> <list name='ignore'/> </query> </iq>

RECV: <body rid='3282533506' xmlns='http://jabber.org/protocol/httpbind'> <presence xmlns='jabber:client' from='[email protected]/yogi' to='msos_ws_candy@satellite-l675/MSOS_ws_Candy'> <x xmlns='http://jabber.org/protocol/muc#user'> <item affiliation='none' role='participant'/> </x> </presence> </body>

So the websocket works but it isn't easy to understand why and how. And the interesting thing is, the SparkWeb demo included with Openfire works fine, but only sends <iq>'s. It doesn't even seem to bother with <stream:...this...> and <stream:...that...> stuff.

So, given limited documentation, I can only conclude that Openfire Websockets only use <iq>'s and my only successful communication was due the the <iq> sent requesting disco#info.

So how do we send a request for authentication? Any reference to good examples or documentation would be greatly appreciated.