So i'm trying to connect to a websocket server using javascript. I tried doing this with NODEJS with the following code and it worked.
const WebSocket = require('ws');
const ws = new WebSocket('<Websocket Address>', {
origin: '<URL>'
});
ws.on('open', function open() {
ws.send(JSON.stringify({"event":"auth","args":["<My authentication token>"]}))
ws.send(JSON.stringify({"event":"send logs","args":[null]}))
console.log('connected');
});
ws.on('close', function close() {
console.log('disconnected');
});
ws.addEventListener('send logs', function (event) {
console.log('Message from server ', event);
});
ws.on('message', function incoming(data) {
console.log(data);
}, 500);
const ws = new WebSocket('<Websocket address>', {
origin: '<URL>'
});
ws.on('open', function open() {
ws.send(JSON.stringify({"event":"auth","args":["<My authentication Token>"]}))
ws.send(JSON.stringify({"event":"send logs","args":[null]}))
console.log('connected');
});
ws.on('close', function close() {
console.log('disconnected');
});
ws.addEventListener('send logs', function (event) {
console.log('Message from server ', event);
});
ws.on('message', function incoming(data) {
console.log(data);
}, 500);