Pat
Pat

Reputation: 167

Strophe.js does not connect to openfire

I set up an openfire server on a server within our network and gave it a domain name. I want to connect to it via my phone in a phonegap app and therefore implemented a strophe.js client within my app.

It works fine on my Nexus 5 (Android 4.4.3), but as soon as I want to run it on my Samsung Galaxy S2 (Android 4.1.2) or the Samsung Galaxy Tab (GT-P7501 - Android 4.0.4) I don't get any response from the server. Here is the code snippet of my connect:

var BOSH_SERVICE = 'http://SERVERNAME:7070/http-bind/';
var connection = null;

$(document).ready(function () {
    connection = new Strophe.Connection(BOSH_SERVICE);
    connection.rawOutput = log;
    connection.rawInput = log;
    connection.connect('id@servername/resource', 'test', onConnect);
});

function log(msg) {
    console.log(msg);
}
function rawInput(data) {
    log('RECV: ' + data);
}
function rawOutput(data) {
    log('SENT: ' + data);
}

the console log will be:

SENT: <body rid='367573377' xmlns='http://jabber.org/protocol/httpbind' to='servername' xml:lang='en' wait='60' hold='1' content='text/xml; charset=utf-8' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>

This will be repeated a few times but I don't get any incoming messages. The servers version number is openfire 3.9.3. As all this code works on my nexus 5 I assume that the code is correct. I Also doubt that my server is configured wrong, nevertheless I included a screenshot of the config settings of the openfire server in the end. The openfire xmpp server is running on a windows server and I access it via wifi/dyndns.

Do you have any ideas why this does not work on the samsung galaxy? Every help will be appreciated. Thanks in advance !

openfire http bind settings

Upvotes: 0

Views: 2070

Answers (1)

Pat
Pat

Reputation: 167

I could "solve" this by myself. It is really not a big deal, but it took me a really long time (3 days) to realize this, so in case anyone will ever come accross the same phenomena this info might help:

In my case all the configurations of the server and the strophe client above are correct. Indeed the only reason the connect did not work properly on all devices seemed to be that these devices could not even ping the server, even though they are in the same network. In my case I gave the server a static domain name, which was the key issue. Somehow the Google Nexus 5 is able to resolve this name to an ip adress via the dns-server, but both the elder samsung galaxy s2 and the samsung galaxy tab aren't.

Solution: I replaced the static domain name with the corresponding ip-adress in my strophe.js connection.

Upvotes: 2

Related Questions