Answer the question
In order to leave comments, you need to log in
Why does the socket return an error?
const WebSocket = require('ws')
const fetch = require('node-fetch')
const hooman = require('hooman')
const eventHandler = msg => {
console.log(msg)
}
;(async () => {
var response = await hooman("https://ws.site.org:2096/socket.io/?EIO=3&transport=polling&t="+ new Date().getTime(), {
"headers": {
"accept": "*/*",
},
"credentials": "include"
});
var data = await response.body
var json = JSON.parse(data.match(/{.+}/)) тут хранится sid нужный для подключения
console.log(json)
const ws = new WebSocket(`wss://ws.site.org:2096/socket.io/?EIO=3&transport=websocket&sid=${json.sid}`);
ws.on('error', error => {
console.error(error)
})
ws.addEventListener('message', eventHandler)
})()
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