【问题标题】:Ejabberd: Failed to start BOSH session when connecting from clientEjabberd:从客户端连接时无法启动 BOSH 会话
【发布时间】:2023-03-31 21:59:01
【问题描述】:

今天我将服务器从 Ubuntu 16.04 升级到 18.04,这还包括从 ejabberd 16.01 到 18.01 的跳转。现在我们遇到了从客户端连接的问题(使用 strophe.js)

[info] <0.359.0>@ejabberd_listener:accept:302 (<0.876.0>) Accepted connection 127.0.0.1:60552 -> 127.0.0.1:8088
[error] <0.876.0>@ejabberd_bosh:start:133 Failed to start BOSH session: {error,{noproc,{gen_server,call,[ejabberd_c2s_sup,{start_child,[{xmpp_socket,{socket_state,ejabberd_bosh,{http_bind,<0.877.0>,{{9x,1xx,2xx,1xx},60552}},infinity,undefined,none,<0.877.0>}},[{receiver,<0.877.0>},{xml_socket,true}]]},infinity]}}}
[error] <0.877.0>@gen_server:call CRASH REPORT Process <0.877.0> with 0 neighbours exited with reason: no such process or port in call to gen_server:call(ejabberd_c2s_sup, {start_child,[{xmpp_socket,{socket_state,ejabberd_bosh,{http_bind,<0.877.0>,{{9x,1xx,2xx,1xx},60552}},...}},...]}, infinity) in p1_fsm:init_it/6 line 392
[error] <0.617.0>@gen_server:call Supervisor 'mod_bosh_chat3.myserver.com' had child undefined started with {ejabberd_bosh,start_link,undefined} at <0.877.0> exit with reason no such process or port in call to gen_server:call(ejabberd_c2s_sup, {start_child,[{xmpp_socket,{socket_state,ejabberd_bosh,{http_bind,<0.877.0>,{{9x,1xx,2xx,1xx},60552}},...}},...]}, infinity) in context child_terminated

我知道 mod_http_bind 已被 mod_bosh 取代。客户端通过 apache 代理从端口 80 连接到 8088。因此,请求 :80/http-bind/ 将被传递到 :8088/bosh/

我还在升级后彻底擦除了 mnesia 数据库,以确保它没有损坏或被弃用。

According to this question,我还检查了是否启用了 curl。

在日志级别调试时,mod_bosh 模块似乎已启动:

[debug] <0.329.0>@gen_mod:start_module:193 loading mod_bosh at jabber.myserver.com
[debug] <0.329.0>@gen_mod:start_module:193 loading mod_push at jabber.myserver.com
[debug] <0.600.0> Supervisor ejabberd_gen_mod_sup started ejabberd_tmp_sup:start_link('mod_bosh_jabber.myserver.com', ejabberd_bosh) at pid <0.651.0>

这是我的完整配置:

loglevel: 5

log_rotate_size: 0
log_rotate_date: ""
log_rate_limit: 100

hosts:
  - "localhost"
  - "jabber.myserver.com"
  - "chat3.myserver.com"
  - "test-chat3.myserver.com"

define_macro:
  'TLS_CIPHERS': "HIGH:!aNULL:!eNULL:!3DES:@STRENGTH"
  'TLS_OPTIONS':
    - "no_sslv3"
    - "no_tlsv1"
    - "cipher_server_preference"
    - "no_compression"

c2s_ciphers: 'TLS_CIPHERS'
s2s_ciphers: 'TLS_CIPHERS'
c2s_protocol_options: 'TLS_OPTIONS'
s2s_protocol_options: 'TLS_OPTIONS'

listen: 

  - 
    port: 8088
    ip: "127.0.0.1"
    module: ejabberd_http
    request_handlers:
      "/bosh": mod_bosh
    web_admin: true
    tls: false

disable_sasl_mechanisms: "digest-md5"
s2s_use_starttls: false
auth_password_format: plain
auth_method: sql

sql_type: mysql
sql_server: "10.0.0.51"
sql_database: "databasename"
sql_username: "username"
sql_password: "secret-as-hell"

shaper:
  normal: 1000
  fast: 50000

max_fsm_queue: 10000

acl:
  admin:
    user:
      - "": "localhost"
      - "admin": "test-chat3.myserver.com"
      - "admin": "chat3.myserver.com"
  local: 
    user_regexp: ""
  loopback:
    ip:
      - "127.0.0.0/8"

shaper_rules:
  max_user_sessions: 10
  max_user_offline_messages:
    - 5000: admin
    - 100
  c2s_shaper:
    - none: admin
    - normal
  s2s_shaper: fast


access_rules:
  local:
    - allow: local
  c2s:
    - deny: blocked
    - allow
  announce:
    - allow: admin
  configure:
    - allow: admin
  muc_create:
    - allow: local
  pubsub_createnode:
    - allow: local
  register:
    - allow
  trusted_network:
    - allow: loopback

api_permissions:
  "console commands":
    from:
      - ejabberd_ctl
    who: all
    what: "*"
  "admin access":
    who:
      - access:
        - allow:
          - acl: loopback
          - acl: admin
      - oauth:
        - scope: "ejabberd:admin"
        - access:
          - allow:
            - acl: loopback
            - acl: admin
    what:
      - "*"
      - "!stop"
      - "!start"
  "public commands":
    who:
      - ip: "127.0.0.1/8"
    what:
      - "status"
      - "connected_users_number"

language: "en"

acme:
  contact: "mailto:example-admin@example.com"
  ca_url: "https://acme-v01.api.letsencrypt.org"


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: {}
  mod_configure: {} # requires mod_adhoc
  mod_disco: {}
  mod_echo: {}
  mod_irc: {}
  mod_bosh: {}
  mod_last: {}
  mod_muc: 
    access:
      - allow
    access_admin:
      - allow: admin
    access_create: muc_create
    access_persistent: muc_create
  mod_muc_admin: {}
  mod_offline: 
    access_max_user_messages: max_user_offline_messages
  mod_ping: {}
  mod_privacy: {}
  mod_private: {}
  mod_pubsub: 
    access_createnode: pubsub_createnode
    ignore_pep_from_offline: true
    last_item_cache: false
    plugins: 
      - "flat"
      - "hometree"
      - "pep" # pep requires mod_caps
  mod_push: {}
  mod_push_keepalive: {}
  mod_roster:
    versioning: true
  mod_shared_roster: {}
  mod_stats: {}
  mod_time: {}
  mod_vcard:
    search: false
  mod_vcard_xupdate: {}
  mod_version: {}
  mod_stream_mgmt:
    resend_on_timeout: if_offline
  mod_s2s_dialback: {}
  mod_http_api: {}

allow_contrib_modules: true

非常感谢任何提示:-)

【问题讨论】:

    标签: xmpp ejabberd ubuntu-18.04


    【解决方案1】:

    您的配置中的问题似乎是您删除了 ejabberd_c2s 侦听器。它是必需的,您可以在错误消息中看到它。所以,问题是通过添加它来解决的,至少在我的情况下,例如:

    listen:
      -
        port: 5222
        module: ejabberd_c2s
      - 
        port: 8088
        ip: "127.0.0.1"
        module: ejabberd_http
        request_handlers:
          "/bosh": mod_bosh
        web_admin: true
        tls: false
    

    ejabberd 文档中没有提到这样的要求,所以我现在添加了。

    【讨论】:

    • 感谢您清除它...我非常确定我的旧配置仅在 8088 上侦听,但显然它也必须包含 5222。我真的必须学习如何阅读这些神秘的错误信息。
    【解决方案2】:

    更新:忘记下面的一切。请看Badlop的回答


    是否完全重新安装了 ejabberd:

    apt-get --purge autoremove ejabberd
    

    (确保 /etc/ejabberd 为空)

    apt-get update
    apt-get upgrade
    apt-get install ejabberd
    

    这里是 ejabberd.yml 的相关部分。我没有改变其他任何东西:

    hosts:
      - "localhost"
      - "chat3.myserver.com" <- the public domain
    
    listen:
      - 
        port: 5222
        ...
      -
        port: 5269
        ...
      -
        ##port: 5280
        port: 8088      <- use any port you like
        ip: "127.0.0.1" <- listen only on localhost
        module: ejabberd_http
        request_handlers:
          "/ws": ejabberd_http_ws
          "/bosh": mod_bosh
          "/api": mod_http_api
        ##  "/pub/archive": mod_http_fileserver
        web_admin: true
        ## register: true
        ## captcha: true
        tls: false  <- no need for tls on localhost
        protocol_options: 'TLS_OPTIONS'
    
    auth_method: sql
    sql_type: mysql
    sql_server: "server"
    sql_database: "ejabberd_live"
    sql_username: "ejabberd"
    sql_password: "secret"
    
    acl:
      admin:
      user:
        - "": "localhost"
        - "admin": "chat3.myserver.com"
    

    如果您想知道我在 apache 中的代理配置。这些是我的 chat3.myserver.com 虚拟主机的相关行:

    ProxyPass /http-bind/ http://127.0.0.1:8088/bosh
    ProxyPassReverse /http-bind/ http://127.0.0.1:8088/bosh
    ProxyPass /admin/ http://127.0.0.1:8088/admin/
    ProxyPassReverse /admin/ http://127.0.0.1:8088/admin/
    

    您当然还需要获取 mysql 数据库架构 from here ... 等等...

    我不知道是什么导致了连接错误。我猜 ejabberd 的升级有些错误。至少我很确定这不是一个已知的错误。我用这个版本的 ejabberd (18.01) 在互联网上爬了 4 个小时,没有找到类似的东西。而且错误消息——即使在日志级别 5 下——也非常模糊。如果这是一个配置错误,我相信错误消息会更加具体。

    【讨论】:

      猜你喜欢
      • 2015-11-15
      • 2014-03-31
      • 2012-03-06
      • 1970-01-01
      • 2011-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-17
      相关资源
      最近更新 更多