我有一个ejabberd客户端,它连接到在strophe.js云上运行的ejabberd服务器。因为这是一个strophe客户端,所以我启用了bosh,我可以在myAWSDNS.com:5280/http-bind/上看到它在运行。我可以使用这个bosh服务通过我的客户端连接到服务器,所以它看起来运行正常。
我还想添加带内注册,为此我使用strophe.register.js
这是我用来做这个的代码:
var tempConn = new Strophe.Connection("http//myAWSDNS.com:5280/http-bind/");
tempConn.register.connect("http://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
}
});如果我进一步深入代码,strophe.js中的这段代码:
_register_cb: function (req) {
var that = this._connection;
Strophe.info("_register_cb was called");
that.connected = true;
var bodyWrap = req.getResponse();bodyWraphas成员outerHTML,它是
"<body xmlns="http://jabber.org/protocol/httpbind" type="terminate" condition="internal-server-error">BOSH module not started</body>"所以,BOSH module not started就是这条消息。
好吧,显然我已经启动了BOSH模块,否则我将无法登录到现有帐户,并与此客户端来回发送东西。然而,它仍然在抱怨这一点,所以我不确定是否需要采取任何额外的步骤来通过bosh启用带内注册。
为了完整起见,下面是ejabberd.cfg的相关部分,首先是bosh:
{5280, ejabberd_http, [
{request_handlers, [
%% {["web"], mod_http_fileserver}
{["xmpp-httpbind"], mod_http_bind}
]},
captcha,
http_bind,
http_poll,
web_admin
]}
]}.这里是带内注册:
{mod_register, [
%%
%% After successful registration, the user receives
%% a message with this subject and body.
%%
{welcome_message, {"Welcome!",
"Welcome to this Jabber server."}},
%%
%% When a user registers, send a notification to
%% these Jabber accounts.
%%
%%{registration_watchers, ["admin1@example.org"]},
{access, register}
]},最后,模块部分:
%%% =======
%%% MODULES
%%
%% Modules enabled in all ejabberd virtual hosts.
%%
{modules,
[
{mod_adhoc, []},
{mod_announce, [{access, announce}]}, % requires mod_adhoc
{mod_caps, []},
{mod_configure,[]}, % requires mod_adhoc
{mod_disco, []},
%%{mod_echo, [{host, "echo.WIN-LV4K7BSUPJO"}]},
{mod_http_bind,[]},
{mod_register,[]},发布于 2014-09-18 03:46:09
据我所知,问题不在于BOSH模块没有启动(显然它已经启动了),而是您对Strophe.register.connect()的调用为domain参数提供了一个完整的URL,而它只需要一个域。您需要做的是向connect()传递myAWSDNS.com而不是URL。
示例:
tempConn.register.connect("myAWSDNS.com", ...);编辑:另外,在你的回调中,你通过connection引用你的连接,在回调之外,你已经定义了tempConn。
https://stackoverflow.com/questions/25874740
复制相似问题