Created
July 3, 2023 19:42
-
-
Save alexb4a/e2d89b1c518dce1edd7a46a74188c9b8 to your computer and use it in GitHub Desktop.
Websocket Client
This file contains 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
// Dont forget to run "npm install ws" so you have the Websockets module installed | |
const WebSocket = require('ws'); | |
const url = 'wss://YourBack4AppContainersAddressHere/'; | |
const connection = new WebSocket(url); | |
connection.onopen = () => { | |
connection.send('Hello Server!'); | |
}; | |
connection.onerror = (error) => { | |
console.log(`WebSocket error: ${error}`); | |
}; | |
connection.onmessage = (e) => { | |
console.log(e.data); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment