what can cause wss to fail with functional https

27 Views Asked by At

wss fails while https is working flawlessly. ws also works well on development machine

const socket = io.connect('wss://' + ENDPOINT + ':3002', {
        path: '/doctor/persona/',
        transports: ['websocket'],
        secure: true
});
const socket = io.connect(ENDPOINT, {
        path: '/doctor/persona/',
        transports: ['websocket'],
        secure: true
});

Tried with and without secure = true

const io = require("socket.io")(server, {
  origins: "*:*",
  path: "/doctor/persona",
  transports: ["websocket"],
  rejectUnauthorized: false
});

EIO=3 whatever that is

The node js server has 2 services one at :3000 primarily dealing with https and another websocket at :3002 for a single websocket.

With nginx, there's a 502 error but the pm2 logs don't seem to update whenever the socket tries, with or without nginx.

location /doctor/persona/ {
                proxy_pass https://localhost:3002/doctor/persona/;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_read_timeout 30s;
                proxy_connect_timeout 15s;
                #proxy_ssl_server_name on;
                proxy_set_header Host $http_host;
                proxy_cache_bypass $http_upgrade;
        }
SSL_do_handshake() failed (SSL: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:SSL alert number 40) while SSL handshaking to upstream

SSL certificates are provided by letsencrypt.

I have tried through nginx proxy, directly accessing the relevant port, etc. Code works perfectly with ws and http. wss has not worked yet and I still don't know what is failing becasue pm2 logs don't show anything!

0

There are 0 best solutions below