无法使用 websocket 通过 Kaiwa 聊天客户端连接到 ejabberd

can't connect to ejabberd through Kaiwa chat client using websocket

我无法通过 Kaiwa 聊天客户端连接到我的 ejabberd 服务器。这是我的 ejabberd 服务器配置:

hosts:
  - "myserver.com"
listen: 
  - 
    port: 5280
    module: ejabberd_http
    certfile: "/Applications/ejabberd-15.10/conf/myserver.pem"
    request_handlers:
      "/websocket": ejabberd_http_ws
    web_admin: true
    http_bind: true
    captcha: false

这是我的 Kaiwa 配置文件:

{
   "isDev": true,
   "http": {
       "host": "localhost",
       "port": 8000
   },
   "server": {
       "domain": "myserver.com",
       "wss": "wss://myserver.com:5280/websocket/"
   }
}

当我尝试登录时出现此错误:

与 'wss://myserver.com:5280/websocket' 的 WebSocket 连接失败:连接建立时出错:net::ERR_CONNECTION_CLOSED

我的ejabberd版本是15.10,应该支持websocket。

如有任何帮助,我将不胜感激。

虽然您为 ejabberd_http 指定了 certfile 选项,但这不足以激活加密(根据使用 wss:// 而不是 ws:// 的要求)。您还需要指定 tls 选项:

hosts:
  - "myserver.com"
listen: 
  - 
    port: 5280
    module: ejabberd_http
    certfile: "/Applications/ejabberd-15.10/conf/myserver.pem"
    request_handlers:
      "/websocket": ejabberd_http_ws
    web_admin: true
    http_bind: true
    captcha: false
    tls: true

问题是 chrome 和 Safari。我不确定为什么,但客户端应用程序与 Mozilla Firefox 完美配合,但无法通过 Safari 或 Chrome 连接。这可能是一个安全设置。 无论如何,切换到 mozilla 解决了我的问题。