Skip to content

Instantly share code, notes, and snippets.

@alexb4a
Created July 3, 2023 19:42
Show Gist options
  • Save alexb4a/e2d89b1c518dce1edd7a46a74188c9b8 to your computer and use it in GitHub Desktop.
Save alexb4a/e2d89b1c518dce1edd7a46a74188c9b8 to your computer and use it in GitHub Desktop.
Websocket Client
// 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