<p>I'm trying to create a Chat application to enhance my portfolio.
For it I'm using xmpp as my messaging server. So, I'm running ejabberd on kubernetes with the following configuration</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ejabberd-depl
  labels:
    app: ejabberd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ejabberd
  template:
    metadata:
      labels:
        app: ejabberd
    spec:
      containers:
      - name: ejabberd
        image: ejabberd/ecs
        ports:
        - containerPort: 5280
        - containerPort: 5222
        - containerPort: 5269
---
apiVersion: v1
kind: Service
metadata:
  name: ejabberd-srv
spec:
  selector:
    app: ejabberd
  ports:
    - name: ejabberd
      protocol: TCP
      port: 5222
      targetPort: 5222
    - name: admin
      protocol: TCP
      port: 5280
      targetPort: 5280
    - name: encrypted
      protocol: TCP
      port: 5269
      targetPort: 5269
</code></pre>
<p>I'm exposing the ejabberd to my entire app using the service.</p>
<p><strong>Connecting to ejabberd using package &quot;@xmpp/client&quot;</strong></p>
<pre><code>import {client, xml, jid} from '@xmpp/client'


const xmpp = client({
      service: &quot;wss://ejabberd-srv:5222/xmpp-websocket&quot;,
      domain: &quot;ejabberd-srv&quot;,
      username: &quot;username&quot;,
      password: &quot;password&quot;,
    })

    xmpp.on('online', () =&gt; {
      console.log(&quot;connected to xmpp server&quot;);

    })

    xmpp.on('error', (err) =&gt; {
      console.log(&quot;Connected but error&quot;);
      
    })

    xmpp.start().catch(() =&gt; console.log(&quot;error in xmpp start&quot;));

</code></pre>
<p>When I run the app the node.js side keeps on giving me errors saying &quot;SSL wrong version number /deps/openssl/ssl/record/ssl3_record.c:354:&quot;</p>
<p><a href="https://i.stack.imgur.com/I9ila.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I9ila.png" alt="The Error" /></a></p>
<p><strong>But when I check the logs of ejabberd it plainly says &quot;Accepted connection&quot;</strong><a href="https://i.stack.imgur.com/7vX0S.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7vX0S.jpg" alt="Ejabberd pod logs" /></a></p>

Jean
<p>I know almost nothing about kubernetes and node.js, but I have experience in ejabberd and docker, so maybe I can give some useful hint:</p>
<p>Looking at the configuration you showed, and assuming you use the default ejabberd config from <a href="https://github.com/processone/docker-ejabberd/blob/master/ecs/conf/ejabberd.yml#L38" rel="nofollow noreferrer">https://github.com/processone/docker-ejabberd/blob/master/ecs/conf/ejabberd.yml#L38</a></p>
<p>In that configuration file it says that:</p>
<ul>
<li>port 5222 is used for XMPP C2S connections</li>
<li>5280 for HTTP connections</li>
<li>and 5443 is used for HTTPS, including WebSocket, BOSH, web admin...</li>
</ul>
<blockquote>
<p>service: &quot;wss://ejabberd-srv:5222/xmpp-websocket&quot;,</p>
</blockquote>
<p>In your case, if your client uses WebSocket to connect to ejabberd, you should open the 5443 port in kubernetes and tell your client to use an URL like &quot;wss://ejabberd-srv:5443/ws&quot;,</p>
