ejabberd http-bind 阻止使用不同资源运行并行会话

Posted

技术标签:

【中文标题】ejabberd http-bind 阻止使用不同资源运行并行会话【英文标题】:ejabberd http-bind prevents running parallel sessions with different resources 【发布时间】:2012-02-25 23:07:00 【问题描述】:

我有一个正在运行的 ejabberd 安装,启用了 http-bindnginx 代理和一个用于 Web 浏览器的迷你 jappix xmpp 客户端。我还有一个外部身份验证程序。

如果我使用经典的 5222 端口,我可以使用不同的资源连接此服务器上的同一用户。但是:

如果我有来自给定用户的经典 xmpp 客户端(psi、同理心)的活动会话,我无法将此用户与 http-bind 连接(401 身份验证失败)。 我的第一个连接是通过 http-bind 建立的,其他经典 xmpp 客户端无法完成其他连接(当然资源也不同)。我有时会收到 401 已连接消息 我只能在一个浏览器中连接同一个用户,我无法在 http-bind 上多次连接同一个用户(这些连接上的资源不同,但我也得到了 401) 我确信当我遇到这些身份验证失败时,外部身份验证程序永远不会启动 max_user_sessions 设置没问题(用无穷大测试),如果我没有在 http-bind 中连接,我可以运行并行会话。但如果我也测试了新的 resource_conflict 设置值但没有成功(实际上这不是资源冲突)

安装:ejabberd-2.1.10 Debian(来自 ejabberd-2.1.10-linux-x86-installer.bin,但在 x86_64 版本中测试过同样的问题)。

配置摘录:

    5280, ejabberd_http, [
                     request_handlers,
                      [
                       ["http_bind"], mod_http_bind
                      ],
                     %%captcha,
                     http_bind,
                     %%http_poll,
                     web_admin
                    ]

在日志上,当这种情况发生时,我有:

=INFO REPORT==== 2012-01-27 10:18:55 ===
D(<0.335.0>:ejabberd_http_bind:684) : reqlist: [hbr,154037,
                             "01775ec6fc089a2b0c84abb80a4b5b7b4bdd958d",
                             [],
                             hbr,154036,
                             "01775ec6fc089a2b0c84abb80a4b5b7b4bdd958d",
                             [xmlstreamelement,
                                   xmlelement,
                                   "stream:features",[],
                                      [xmlelement,
                                          "mechanisms",
                                          ["xmlns",
                                            "urn:ietf:params:xml:ns:xmpp-sasl"],
                                          [xmlelement,
                                            "mechanism",[],
                                            [xmlcdata,
                                              "PLAIN"]]],
                                      xmlstreamstart,
                                       "stream:stream",
                                       ["version","1.0",
                                        "xml:lang","fr",
                                        "xmlns","jabber:client",
                                        "xmlns:stream",
                                         "http://etherx.jabber.org/streams",
                                        "id","3595609800",
                                        "from",
                                         "tchat.example.com"]]]

=INFO REPORT==== 2012-01-27 10:18:55 ===
D(<0.335.0>:ejabberd_http_bind:732) : really sending now: [xmlelement,
                                        "auth",
                                        ["xmlns",
                                        "urn:ietf:params:xml:ns:xmpp-sasl",
                                         "mechanism",
                                          "PLAIN"],
                                         [xmlcdata<<"bGRhcHVzZX(...)3">>]]
=INFO REPORT==== 2012-01-27 10:18:55 ===
I(<0.336.0>:ejabberd_c2s:649) : (socket_state,ejabberd_http_bind,http_bind,<0.335.0>,127,0,0,1,50992,ejabberd_http_bind) Failed authentication for foo38@tchat.example.com

=INFO REPORT==== 2012-01-27 10:18:55 ===
D(<0.337.0>:ejabberd_http_bind:916) : OutPacket: [xmlstreamelement,
                                       xmlelement,"failure",
                                        ["xmlns",
                                          "urn:ietf:params:xml:ns:xmpp-sasl"],
                                        [xmlelement,
                                          "not-authorized",[],
                                          []]]

=INFO REPORT==== 2012-01-27 10:18:55 ===
D(<0.337.0>:ejabberd_http_bind:1054) :  --- outgoing data ---
<body xmlns='http://jabber.org/protocol/httpbind'><failure xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><not-authorized/></failure></body>

那么这是 http-bind 中的“功能”吗?使其成为激活时给定用户的唯一有效资源?如果是,如何为同一个用户运行多个 http 绑定会话?有什么提示吗?

【问题讨论】:

【参考方案1】:

不,您的配置一定有问题。我已经成功使用 ejabberd 的 http-bind 很长时间了,当然你可以有不同资源的多个连接,并且独立于其他客户端连接。我也使用 nginx 作为代理。在你的 ejabberd.cfg 中你应该有:

  5280, ejabberd_http, [
   http_bind, 
   web_admin
  ]

modules,[
      mod_http_bind,[],
      ...
].

另外,我在您的日志中看到"from", "tchat.example.com",这似乎表明配置错误。

【讨论】:

tchat.example.com 实际上是用于该 ejabberd 服务器的正确 serverName。这也是bosh网站的名称。为什么会是误会?现在我删除了配置中的 request_handler 部分,目前没有任何成功......至少你可以告诉我它应该工作:-) 标记为已接受,至少您告诉我它应该可以工作:-)。真正的解决方法是我需要 extauth_cache, false。所以这是外部认证缓存的问题。 我正在使用基于令牌的身份验证,但 autcache 阻止了我的外部身份验证脚本,并且只保留了一个令牌。我想我现在有一些新问题要解决 :-)

以上是关于ejabberd http-bind 阻止使用不同资源运行并行会话的主要内容,如果未能解决你的问题,请参考以下文章

ejabberd.yml 为 strophe 配置注册一个新用户

使用 strophe 和 ejabberd bosh 连接到 localhost 上的 jid 帐户时连接失败

在 ejabberd 中使用 mod_apns.erl 不应收到被阻止的用户的通知

Strophe.js 注册插件不起作用

我可以创建一个围墙花园,只允许我组织的用户使用我的 ejabberd 实例

xmpp ejabberd - 查询用户存在