无法从 ejabberd 列出 muc 房间

Posted

技术标签:

【中文标题】无法从 ejabberd 列出 muc 房间【英文标题】:Cannot list muc rooms from ejabberd 【发布时间】:2016-04-14 09:32:18 【问题描述】:

我的 ejabberd 服务器出现错误。 似乎 ejabberd 想从 Conference.localhost 中列出,而不是从我的真实主机 Conference.xmpp.mydomain.com 中列出。

2016-04-14 11:03:49.167 [info] <0.982.0>@ejabberd_s2s:new_connection:406 New s2s connection started <0.992.0>
2016-04-14 11:03:49.168 [info] <0.992.0>@ejabberd_s2s_out:log_s2s_out:1253 Trying to open s2s connection: xmpp.mydomain.com -> conference.localhost with TLS=true
2016-04-14 11:03:49.183 [info] <0.992.0>@ejabberd_s2s_out:open_socket:246 s2s connection: xmpp.mydomain.com -> conference.localhost (remote server not found)
2016-04-14 11:03:51.939 [info] <0.992.0>@ejabberd_s2s_out:handle_info:940 Reconnect delay expired: Will now retry to connect to conference.localhost when needed.

这是我的 ejabberd.yml [已编辑]:

websocket_ping_interval: 60
websocket_timeout: 86400

loglevel: 4
log_rotate_size: 10485760
log_rotate_date: ""
log_rotate_count: 1

hosts:
  - "xmpp.mydomain.com"

listen: 
  - 
    port: 5222
    module: ejabberd_c2s
    max_stanza_size: 65536
    shaper: c2s_shaper
    access: c2s
  - 
    port: 5269
    module: ejabberd_s2s_in

  -
    port: 5280
    ip: "::"
    module: ejabberd_http
    hosts:
      - "xmpp.mydomain.com"
    request_handlers:
      "/websocket": ejabberd_http_ws
    web_admin: true
    http_bind: true
  -
    port: 5285
    module: ejabberd_http
    hosts:
      - "xmpp.mydomain.com"
    request_handlers:
       "/rest": mod_rest

s2s_use_starttls: optional
s2s_certfile: "/etc/ejabberd/ejabberd.pem"

##
## mysql server:
##
odbc_type: mysql
odbc_server: "localhost"
odbc_database: "ejabberd"
odbc_username: "ejabberd"
odbc_password: "pwd"

shaper:
  normal: 1000
  fast: 50000

max_fsm_queue: 1000

###.   ====================
###'   ACCESS CONTROL LISTS
acl:    
  admin:
    user:
      - "admin": "xmpp.mydomain.com"
  local: 
    user_regexp: ""

  loopback:
    ip:
      - "127.0.0.0/8"

###.  ============
###'  ACCESS RULES
access:
  ## Maximum number of simultaneous sessions allowed for a single user:
  max_user_sessions: 
    all: 10
  ## Maximum number of offline messages that users can have:
  max_user_offline_messages: 
    admin: 5000
    all: 100
  ## This rule allows access only for local users:
  local: 
    local: allow
  ## Only non-blocked users can use c2s connections:
  c2s: 
    blocked: deny
    all: allow
  ## For C2S connections, all users except admins use the "normal" shaper
  c2s_shaper: 
    admin: none
    all: normal
  ## All S2S connections use the "fast" shaper
  s2s_shaper: 
    all: fast
  ## Only admins can send announcement messages:
  announce: 
    admin: allow
  ## Only admins can use the configuration interface:
  configure: 
    admin: allow
  ## Admins of this server are also admins of the MUC service:
  muc_admin: 
    admin: allow
  ## Only accounts of the local ejabberd server can create rooms:
  muc_create: 
    local: allow
  ## All users are allowed to use the MUC service:
  muc: 
    all: allow
  ## Only accounts on the local ejabberd server can create Pubsub nodes:
  pubsub_createnode: 
    local: allow
  ## In-band registration allows registration of any possible username.
  ## To disable in-band registration, replace 'allow' with 'deny'.
  register: 
    all: allow
  ## Only allow to register from localhost
  trusted_network: 
    loopback: allow

language: "en"

###.  =======
###'  MODULES

modules: 
  mod_adhoc: 
  mod_admin_extra: 
  mod_announce: # recommends mod_adhoc
    access: announce
  mod_blocking:  # requires mod_privacy
  mod_caps: 
  mod_carboncopy: 
  mod_client_state:
    drop_chat_states: true
    queue_presence: false
  mod_configure:  # requires mod_adhoc
  mod_disco: 
  ## mod_echo: 
  mod_irc: 
  mod_http_bind: 
  ## mod_http_fileserver:
  ##   docroot: "/var/www"
  ##   accesslog: "/var/log/ejabberd/access.log"
  mod_last: 
    iqdisc: one_queue
    db_type: odbc
  mod_mam:
    iqdisc: one_queue
    db_type: odbc
    default: always
  mod_muc: 
    ## host: "conference.@HOST@"
    access: muc
    access_create: muc_create
    access_persistent: mud_create
    access_admin: muc_admin
    db_type: odbc
    default_room_options:
        mam: true
        public: false
        public_list: false
        allow_change_subj: false
        allow_user_invites: false
        members_only: false
        members_by_default: false
        anonymous: false
        allow_private_messages: true
        persistent: true
  mod_muc_admin: 
  ## mod_muc_log: 
  ## mod_multicast: 
  mod_offline:
    db_type: odbc 
    access_max_user_messages: max_user_offline_messages
  mod_ping: 
  ## mod_pres_counter:
  ##   count: 5
  ##   interval: 60
  mod_privacy: 
  mod_private: 
  ## mod_proxy65: 
  mod_rest:
    allowed_ips: all
  mod_pubsub: 
    access_createnode: pubsub_createnode
    ## reduces resource comsumption, but XEP incompliant
    ignore_pep_from_offline: true
    ## XEP compliant, but increases resource comsumption
    ## ignore_pep_from_offline: false
    last_item_cache: false
    plugins: 
      - "flat"
      - "hometree"
      - "pep" # pep requires mod_caps
  mod_register: 
    welcome_message: 
      subject: "Welcome!"
      body: |-
        Hi.
        Welcome to this XMPP server.

    access: register
  mod_roster: 
  mod_shared_roster: 
  mod_stats: 
  mod_time: 
  mod_vcard: 
  mod_version: 

我在另一台机器上使用了相同的配置,没有错误。 我不明白我在这里缺少什么

感谢您的帮助

[编辑] 2016 年 4 月 18 日: 1/ 客户:

<iq from='j9albn7dju@xmpp.mydomain.com/null' to='xmpp.mydomain.com' type='get' xmlns='jabber:client' id='2:sendIQ'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq> 

2/ 服务器:

<iq xmlns='jabber:client' from='xmpp.mydomain.com' to='j9albn7dju@xmpp.mydomain.com/null' id='2:sendIQ' type='result'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item jid='conference.xmpp.mydomain.com'/>
<item jid='echo.xmpp.mydomain.com'/>
<item jid='irc.xmpp.mydomain.com'/>
<item jid='pubsub.xmpp.mydomain.com'/>
</query>
</iq> 

3/ 客户:

<iq to='conference.xmpp.mydomain.com' from='j9albn7dju@xmpp.mydomain.com/null' type='get' xmlns='jabber:client' id='78:sendIQ'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>

4/ 服务器:

<iq xmlns='jabber:client' from='conference.xmpp.mydomain.com' to='j9albn7dju@xmpp.mydomain.com/null' id='78:sendIQ' type='result'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item jid='conference.localhost' node='emptyrooms' name='Empty Rooms'/>
</query>
</iq>

【问题讨论】:

请展示您的完整配置,包括模块配置。 嗨@MickaëlRémond 我在***.com/questions/32988750/… 上看到了你的回答,但我不确定如何检查第二点。 您的域是 xmpplocal.mydomain.com,您正在尝试访问 Conference.xmpp.mydomain.com。看起来不匹配。 您好,我从其他服务器复制了 yml,现在已修复。我尝试取消注释 host: "conference.@HOST@" 行并将其强制为 host: "conference.xmpp.partymatching.com" 我还尝试将 xmpp.partymatching.com 在我的主机文件中添加为 127.0.0.1,但它不起作用。 可能您的发现数据包错误。请显示您发送的 XMPP 数据包以发现 MUC 房间。我认为您的客户可能针对的是 Conference.localhost 而不是 Conference.xmpp.mydomain.com 【参考方案1】:

几天前我们刚刚遇到了同样的问题。我们深入研究 Ejabberd 代码。请参阅第 614 行附近的mod_muc。我们发现:

    iq_disco_items(Host, From, Lang, &lt;&lt;&gt;&gt;, none) 检查给定主机中的可用房间是否超过 MAX_ROOMS_DISCOITEMS,设置为 100。

    case语句之后,它会进一步调用iq_disco_items(Host, From, Lang, &lt;&lt;"nonemptyrooms"&gt;&gt;, none)

    XmlEmpty = #xmlelname = <<"item">>, attrs = [<<"jid">>, <<"conference.localhost">>, <<"node">>, <<"emptyrooms">>, <<"name">>, translate:translate(Lang, <<"Empty Rooms">>)], children = []

这就是&lt;item jid='conference.localhost' node='emptyrooms' name='Empty Rooms'/&gt; 的来源。

解决方案

我们决定使用RSM 发送迪斯科查询。它将与iq_disco_items(Host, From, Lang, _DiscoNode, Rsm) 进行模式匹配。希望对您有所帮助。

【讨论】:

嗨@KarolDanutama,我们将尝试您的解决方案。我希望我们可以在 conversejs 中做同样的事情。

以上是关于无法从 ejabberd 列出 muc 房间的主要内容,如果未能解决你的问题,请参考以下文章

eJabberd 不能邀请多个用户到多个 MUC 房间

不允许任何所有者撤销创建房间/MUC 的用户的所有权 - Ejabberd XMPP

ejabberd:使用 ejabberdctl 操作书签

使用 ejabberd 实现群聊 [关闭]

Ejabberd:MUC 中的其他消息类型

发送直接邀请不适用于 MUC [ejabberd mod muc 管理员]