首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XMPP ejabberd带内注册:接收xml BOSH未启动,即使它已启动

XMPP ejabberd带内注册:接收xml BOSH未启动,即使它已启动
EN

Stack Overflow用户
提问于 2014-09-17 01:13:21
回答 1查看 558关注 0票数 0

我有一个ejabberd客户端,它连接到在strophe.js云上运行的ejabberd服务器。因为这是一个strophe客户端,所以我启用了bosh,我可以在myAWSDNS.com:5280/http-bind/上看到它在运行。我可以使用这个bosh服务通过我的客户端连接到服务器,所以它看起来运行正常。

我还想添加带内注册,为此我使用strophe.register.js

这是我用来做这个的代码:

代码语言:javascript
复制
        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中的这段代码:

代码语言:javascript
复制
    _register_cb: function (req) {
    var that = this._connection;

    Strophe.info("_register_cb was called");
    that.connected = true;

    var bodyWrap = req.getResponse();

bodyWraphas成员outerHTML,它是

代码语言:javascript
复制
"<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:

代码语言:javascript
复制
{5280, ejabberd_http, [
                         {request_handlers, [
             %% {["web"], mod_http_fileserver}
                {["xmpp-httpbind"], mod_http_bind}
             ]},
             captcha,
             http_bind, 
             http_poll, 
             web_admin
            ]}

 ]}.

这里是带内注册:

代码语言:javascript
复制
  {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}
     ]},

最后,模块部分:

代码语言:javascript
复制
    %%%   =======
%%%   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,[]},
EN

回答 1

Stack Overflow用户

发布于 2014-09-18 03:46:09

据我所知,问题不在于BOSH模块没有启动(显然它已经启动了),而是您对Strophe.register.connect()的调用为domain参数提供了一个完整的URL,而它只需要一个域。您需要做的是向connect()传递myAWSDNS.com而不是URL。

示例:

代码语言:javascript
复制
tempConn.register.connect("myAWSDNS.com", ...);

编辑:另外,在你的回调中,你通过connection引用你的连接,在回调之外,你已经定义了tempConn

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25874740

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档