ejabberd connection failed with webclient(websocket.js)
Asked Answered
S

1

7

I have installed ejabberd with Ubunut OS.

  1. Configured ejabberd.yml as:

    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

Note: able to connect and chat using jabber client and spark also.

Try to connect with webclient as get response as below:

     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>

what's missing in server configuration or websocket.js configuration?

Seduction answered 26/5, 2018 at 14:1 Comment(0)
S
0

This was just problem with web-socket client, it was using old web-socket protocol version, that was available before xmpp over web-socket was standarized, I got new updated web-socket client where that client to use new protocol, Now it's working. Thanks to ejabberd team for update.

Seduction answered 6/6, 2018 at 18:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.