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

Posted

技术标签:

【中文标题】XMPP ejabberd 带内注册:接收 xml BOSH 未启动,即使它是【英文标题】:XMPP ejabberd in-band registration: receive xml BOSH not started, even though it is 【发布时间】:2014-09-16 17:13:21 【问题描述】:

我有一个 strophe.js xmpp 客户端,它连接到运行在亚马逊云上的 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,[],

【问题讨论】:

【参考方案1】:

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

例子:

tempConn.register.connect("myAWSDNS.com", ...);

编辑: 此外,在您的回调中,您通过 connection 引用您的连接,其中在回调之外您已定义 tempConn

【讨论】:

您好科尔顿,感谢您的回复。我想尝试您的解决方案,但不幸的是,我遇到了另一个可能与 ejabberd 无关的问题。每当我重新安装和配置 ejabberd 时,一段时间后,登录就不再起作用了。然后我重新安装,过了一会儿,登录再次中断。无限重复。无论如何,一旦我克服了这一点,我会尝试你的建议!谢谢:) 好的,所以我无法找到 ejabberd 问题的根源(为什么它会在一段时间后一直中断),所以我改用 openfire 3.10.0 alpha。注册在那里也不起作用,但它表现出不同的行为,所以我在***.com/questions/25916578/… 提出了一个单独的问题,当然,我采纳了你的建议。感谢您迄今为止的帮助! 我想我刚刚注意到您的代码存在另一个问题,请查看我编辑的答案。我认为 OpenFire 会给你带来更好的运气。 ...也就是说,直到您开始遇到来自 OF 的内置 BOSH 连接管理器的间歇性“客户端提供无效 SID”错误。

以上是关于XMPP ejabberd 带内注册:接收 xml BOSH 未启动,即使它是的主要内容,如果未能解决你的问题,请参考以下文章

Ejabberd,Python:检查用户,如果没有创建

XMPP 带内注册(XEP-0077):与简单的 jid/pw 登录不同,都有哪些步骤?

通过 Bosh 进行的 Openfire 带内注册无法与 Strophe/Strophe.register.js 一起使用

SIP/XMPP:ejabberd 和 mod_register:注册:禁止

无法将用户从 iOS 客户端注册到 Ejabberd 服务器 - XMPP

操作无法完成。 (kCFStreamErrorDomainSSL 错误 -9847。)使用 xmpp 聊天在 ejabberd 中注册新用户时