我之前问过一个关于ejabberd的类似问题,但是ejabberd给出了其他问题,所以我选择了openfire。为了不把原来的问题弄得乱七八糟,我决定提出一个新的问题,因为这个问题与我与ejabberd有关的问题是一个不同的问题。
所以,问题来了:
我有一个strophe.js xmpp客户端,它连接到运行在亚马逊云上的openfire 3.10.0alpha服务器。我需要3.10.0alpha而不是3.9.3,因为bfix包含在前者中,而不是latter.Anyway中,因为这是一个strophe客户端,我已经启用了bosh,并且我可以看到它在myAWSDNS.com:7070上运行。我能够连接到服务器通过我的客户端使用这个bosh服务和现有帐户,并发送消息来回,因此它似乎运行良好。
我还想添加带内注册,我使用strophe.register.js。
这是我所使用的代码:
var tempConn = new Strophe.Connection("http//myAWSDNS.com:7070/http-bind/");
tempConn.register.connect("myAWSDNS.com", function (status) {
if (status === Strophe.Status.REGISTER) {
// fill out the fields
connection.register.fields.username = "juliet";
connection.register.fields.password = "R0m30";
// calling submit will continue the registration process
connection.register.submit();
} else if (status === Strophe.Status.REGISTERED) {
console.log("registered!");
// calling login will authenticate the registered JID.
connection.authenticate();
} else if (status === Strophe.Status.CONFLICT) {
console.log("Contact already existed!");
} else if (status === Strophe.Status.NOTACCEPTABLE) {
console.log("Registration form not properly filled out.")
} else if (status === Strophe.Status.REGIFAIL) {
console.log("The Server does not support In-Band Registration")
} else if (status === Strophe.Status.CONNECTED) {
// do something after successful authentication
} else {
// Do other stuff
}
});这似乎很好,因为它进入第一个if-括号(status === Strophe.Status.REGISTER),并尝试设置connection.register.fields.username = "juliet";。
但是,在这里,在执行该行时,它跳入strophe.js行2476:
if (this.connect_callback) {
try {
this.connect_callback(status, condition);
} catch (err) {
Strophe.error("User connection callback caused an " +
"exception: " + err);
}
}其中2476是catch(err) { ...... }括号中的代码。
如果我检查err,我得到的就是:

因此,信息:connection is not defined和,显然,重组不起作用,我不知道为什么。有人对此有任何意见吗?
谢谢,并致以最良好的问候
克里斯
发布于 2014-09-18 15:27:27
你可能不喜欢这个答案..。connection == undefined的原因是因为您将其命名为tempConn。
https://stackoverflow.com/questions/25916578
复制相似问题