N
N
Nikolay372019-09-03 00:47:06
Node.js
Nikolay37, 2019-09-03 00:47:06

How to connect to socket.io server?

Good day, I'm trying to connect to sockets (as a client), nothing happens. How can I find out the connection status? The final path, after connecting to the site in the browser:
wss://....com/app1socket/?EIO=3&transport=websocket&sid=...
Previously, I only saw this one: wss://....com/socket.io /?EIO=3&transport=websocket&sid=...
Could this somehow affect the connection method? I noticed that the version of socket.io on one site is 1.2.0, on the other 1.4.5 (it just doesn’t work here)
Here is the code:

var socket = io("wss://....com", {
    extraHeaders: {
      'origin': 'https://....com',
      'Referer': 'https://....com/',
      'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36'
    }
  });

  socket.on('connect', () => {
    console.log('подключился')
  });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question