无法在 windows phone 7.5(vs2010) 上使用 strophe.js 保持与 XMPP 服务器的连接
Posted
技术标签:
【中文标题】无法在 windows phone 7.5(vs2010) 上使用 strophe.js 保持与 XMPP 服务器的连接【英文标题】:unable to keep the connection with XMPP server using strophe.js on windows phone 7.5(vs2010) 【发布时间】:2013-08-08 09:07:06 【问题描述】:我在android 2.3中使用PhoneGap和strophe.js连接openfire,成功并保持连接。
但我在 Windows Phone 7 中使用相同的代码,它首先连接并可以获取消息。但它在几分钟或几秒钟内CONNFAIL。
CONNECTING->AUTHENTICATING->CONNECTED->DISCONNECTING->CONNFAIL->DISCONNECTED
CONNECTED 和 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));
没有错误信息,只有 strophe 状态日志:
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 7.8 的 Windows Phone SDK 更新
PhoneGap-2.9.0, Windows Phone 7, Openfire 3.7.1, jquery.mobile-1.2.0.min.js, strophejs-1.0.2
【问题讨论】:
【参考方案1】:您应该能够在 BOSH 连接器的 POST 响应中看到错误:请在此处复制粘贴最后一个。
【讨论】:
【参考方案2】:我认为这可能与发现的事情有关 here - 如果应用程序进入后台,Windows 7/8 不会为应用程序打开套接字。
【讨论】:
以上是关于无法在 windows phone 7.5(vs2010) 上使用 strophe.js 保持与 XMPP 服务器的连接的主要内容,如果未能解决你的问题,请参考以下文章
在 Windows Phone 7.5 Mango 中实现闹钟
windows phone 7 或 7.5 是不是可以更新到 IE10? [关闭]
在 windows phone 7.5 中使用拖动事件在网格中切换矩形
如何让您的 Windows Phone 7.5 应用程序保持领先