I am using ws
npm in the server side, websocket in the client side.
When running this code from node-js it works fine, but running it from the browser gives the following error:
failed: Error in connection establishment: net::ERR_CERT_COMMON_NAME_INVALID
const ws = new WebSocket('wss://domain:port', null, {
rejectUnauthorized: false
});
ws.onerror = function (e) {
console.log(e)
}
ws.onclose = function (e) {
console.log(e)
}
ws.onopen = function () {
console.log('connected ')
ws.send(JSON.stringify({ msg: 'msg' }));
}