Konubinix' opinionated web of thoughts

How to Connect to a Websocket With a Self Signed Certificate in Nodejs

Fleeting

How to connect to a websocket with a self signed certificate in nodejs.

npm init
npm install websocket
WebSocket = require("websocket")
var server = "wss://wallet.localtest.me/api/v0/broker"
// server = "wss://testing.sdk.eniblock.com/api/v0/broker"
const socket = new WebSocket.w3cwebsocket(server, null, null, null, {rejectUnauthorized: false})
socket.addEventListener("open", (event) => {
    console.log("Connection opened!");
});
socket.addEventListener("error", (event) => {
    console.log("Connection error!", event);
});