Score:0

NodeJS Unable to connect to Websocket Cross origin - "Err 1006"

cn flag

I have a two webservers both running https with the same certificates, I have a main shard that the user connects to example.com, they retrieve some data and try to connect to an ip address on the 2nd shard via websocket.

But no matter what I configure I get an Error 1006 on the client side when connecting to the 2nd shard. Firefox devtooling gives me multiple errors - ssl_error_bad_cert_domain, SSL_ERROR_RX_RECORD_TOO_LONG.

The certificates are issued and signed, I was wondering where I should go from here. Thanks :)

SHARD2

const options = {
    key: './server.key',
    cert: './server.cert'
};

var https = require('https').Server(options);

https.listen(443, function () {
    // console.log('Https listening on *: 443');
});

let WebSocket = require('ws');

let socket = new WebSocket.Server({ server:https });

socket.on('connection', function (ws, req) {

    ws.on('message', (msgRaw) =>{

    });

    ws.on('close', function(code, reason) {

    });

    ws.on('error', function(error) {
        console.log(error);
        ws.close();
    });
});

CLIENT

function connect() {
    "use strict";

    window.WebSocket = window.WebSocket || window.MozWebSocket;

    if (!window.WebSocket) {
        alert('Your browser doesn\'t support WebSocket');
        return;
    }

    wss = new WebSocket('wss://123.123.123.120/:443');

    wss.onmessage = function(event) {

    };

    wss.onerror = function(event) {
        console.log(`wss error: ${JSON.stringify(event)}`);
    };

    wss.onclose = function(event) {

    };
}

Useful sys diagram?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.