Answer the question
In order to leave comments, you need to log in
How to properly connect to websocket via socket.io-client?
I want to connect to a websocket of a third-party site, the connection occurs, but since I can’t figure out how to add namespace: 'App.Info' and subscribe to the 'db.list' channel and listen to the 'ResponseData' event, nothing happens.
Mb someone will help what and how in these web sockets)
const io = require("socket.io-client"); // v2.3.1
const socket = io('wss://example:2020');
socket.on('connect', () => {
console.log('connect'); // connect
console.log(socket.id); // uS4yrcsOEqxZ3kMqEVyB
socket.send(JSON.stringify({'namespace': 'App.Info'}));
socket.emit('db.list');
});
socket.on('ResponseData', data => {
console.log(data);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question