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

时间:2018-05-26 14:01:08

标签: websocket xmpp ejabberd strophe

我已经在Ubunut OS上安装了ejabberd。

  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. Webclient:https://github.com/processone/xmpp-websocket-client

  3. 注意:能够使用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配置中缺少什么?

1 个答案:

答案 0 :(得分:0)

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