0
votes

I use PhoneGap with strophe.js to connect openfire in android 2.3, it's Success and keep the connection.

But I use the same code in Windows Phone 7, it connect first and can get message. But it's CONNFAIL in few minutes or seconds.

CONNECTING->AUTHENTICATING->CONNECTED->DISCONNECTING->CONNFAIL->DISCONNECTED

There is no same times between CONNECTED and DISCONNECTING.

var username=XXX;
var HOST_DOMAIN=XXX;
var password=XXX;
var BOSH_SERVICE = "http://127.0.0.1:7070/http-bind/";
connection = new Strophe.Connection(BOSH_SERVICE);
connection.connect(username + "@" + HOST_DOMAIN, password, onConnect);
function onConnect(status) {
    if (status == Strophe.Status.CONNECTED) {
        connection.addHandler(notifyUser, null, "message", null, null, null);
    connection.send($pres().tree());
    }else if (status == Strophe.Status.DISCONNECTED) {
        console.log("Strophe is disconnected.");
    }
}
function notifyUser(msg) {
    console.log("msg : " + Strophe.serialize(msg));
}

No error message,only the strophe status log:

Log:["status=1","DebugConsole1005374909"]
Log:["Current Status is [CONNECTING]","DebugConsole1005374910"]
Log:["Strophe is connecting.","DebugConsole1005374911"]
Log:["status=3","DebugConsole1005374912"]
Log:["Current Status is [AUTHENTICATING]","DebugConsole1005374913"]
Log:["status=5","DebugConsole1005374914"]
Log:["Strophe is connected.","DebugConsole1005374916"]
Log:["Current Status is [CONNECTED]","DebugConsole1005374915"]

GapBrowser_Navigated :: /app/www/login.html#eventList

Log:["Strophe is disconnecting.","DebugConsole1005374922"]
Log:["status=2","DebugConsole1005374917"]
Log:["Current Status is [CONNFAIL]","DebugConsole1005374918"]
Log:["Strophe failed to connect.","DebugConsole1005374919"]。
Log:["status=7","DebugConsole1005374920"]
Log:["Current Status is [DISCONNECTING]","DebugConsole1005374921"]
Log:["Strophe is disconnected.","DebugConsole1005374925"]
Log:["status=6","DebugConsole1005374923"]
Log:["Current Status is [DISCONNECTED]","DebugConsole1005374924"]

Visual Studio 2010,
Windows Phone SDK update for Windows Phone 7.8

PhoneGap-2.9.0,
Windows Phone 7,
Openfire 3.7.1,
jquery.mobile-1.2.0.min.js,
strophejs-1.0.2

2

2 Answers

0
votes

You should be able to see the errors in the POST responses from the BOSH connector: please copy-paste the last here.

0
votes

I think it could be related to the thing discovered here - Windows 7/8 doesn't keep sockets open for an application if it goes in the background.