Last active
April 16, 2021 12:35
-
-
Save suru-dissanaike/a15f00882a98741d95e64d861b0f5c30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const WebSocket = require('ws'); | |
// in order to handle self-signed certificates we need to turn off the validation | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; | |
const ws = new WebSocket('wss://localhost:8080'); | |
ws.on('open', function open() { | |
ws.send('hello from client'); | |
}); | |
ws.on('message', function incoming(data) { | |
console.log(data); | |
ws.close(); // Done | |
}); | |
ws.addEventListener('error', (err) => console.log(err.message)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment