ejabberd 连接失败与 webclient(websocket.js)

ejabberd connection failed with webclient(websocket.js)

我已经用 Ubunut 安装了 ejabberd OS。

  1. 配置ejabberd.yml为:

    port: 5280
        ip: "::"
        module: ejabberd_http
        request_handlers:
          "/ws": ejabberd_http_ws
          "/bosh": mod_bosh
          "/a/b/": mod_foo
          "/api": mod_http_api
        web_admin: true
        http_bind: true
        register: true
        captcha: true
    
  2. 网络客户端:https://github.com/processone/xmpp-websocket-client

注意:还可以使用 jabber 客户端和 spark 进行连接和聊天。

尝试连接 webclient,得到如下响应:

     client Request: <?xml version="1.0"?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0"
 xmlns="jabber:client" to="localhost" xml:lang="en"
 xmlns:xml="http://www.w3.org/XML/1998/namespace" >

     Server Response: <stream:stream id='14754768778694635521' version='1.0' xml:lang='en'
 xmlns:stream='http://etherx.jabber.org/streams' from='localhost'
 xmlns='jabber:client'>

     <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>PLAIN</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms></stream:features>

     Client request: <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>

     Server Response: <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjE2NDY5ODExMTQ0NDkyMDQyMjQxIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNz</challenge>

     Client Request: <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>dXNlcm5hbWU9Im1hbm9qIixyZWFsbT0iIixub25jZT0iMTY0Njk4MTExNDQ0OTIwNDIyNDEiLGNub25jZT0iZDQxZDhjZDk4ZjAwYjIwNGU5ODAwOTk4ZWNmODQyN2UiLG5jPSIwMDAwMDAwMSIscW9wPSJhdXRoIixkaWdlc3QtdXJpPSJ4bXBwL2xvY2FsaG9zdCIscmVzcG9uc2U9ImJhMjhjNTQwYzU5ZTczZGE1NGY1MmU2YjYxYTFhMjlmIixjaGFyc2V0PSJ1dGYtOCI=</response> 

     Server Response: <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD0xMzc3MzJjMzc3M2FhMjIxNzg0Y2RmYTIxY2RkNzZjMQ==</challenge>

     CR: <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>

     SR <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>

     CR: <?xml version="1.0"?><stream:stream xmlns:stream="http://etherx.jabber.org/streams" version="1.0"
 xmlns="jabber:client" to="localhost" xml:lang="en"
 xmlns:xml="http://www.w3.org/XML/1998/namespace" >

     SR: <stream:stream id='2280662148453655041' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams'
 xmlns='jabber:client'>

     <stream:error><not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xml:lang='en'
 xmlns='urn:ietf:params:xml:ns:xmpp-streams'>XML or text declaration
 not at start of entity</text></stream:error>

     </stream:stream>

服务器配置或 websocket.js 配置中缺少什么?

这只是 web-socket 客户端的问题,它使用旧的 web-socket 协议版本,在 xmpp over web-socket 标准化之前可用,我得到了新的更新的 web-socket 客户端,客户端可以使用新协议,现在可以使用了。感谢 ejabberd 团队的更新。