Socket.io is constantly conducting a survey ... if so?

I have a node server and a webpage connected via socket.io. I noticed in the browser console that it displays

XHR finished loading: GET "http://my_url/socket.io/?EIO=3&transport=polling&t=1418944327412-412&sid=vqLTUtW3QhNLwQG8AAAA".

and

XHR finished loading: POST "http://my_url/socket.io/?EIO=3&transport=polling&t=1418944385398-415&sid=vqLTUtW3QhNLwQG8AAAA".

every few seconds. If so, or I am missing the settings. I really only want to send data back and forth explicitly through the socket. Maybe I missed something in the setup.

Client side mainly

var socket = io("http://my_url");

with ordinary event listeners. Server side

var io = require('socket.io')(server);

I tried to host this server side

io.set('transports', ['websocket']);

but that seemed to kill him.

+4
source share
1 answer

socket.io ( -) ( ) , , . .

HTTP- ( websocket), http, socket.io webSocket, HTTP. socket.io webSocket, ( ).

, , . socket.io HTTP- , HTTP-. webSocket , , "" webSocket. TCP-, TCP, . webSockets, webSocket, TCP-. , . Chrome http-, websocket, webSocket. , , webSocket, , HTTP- ( , , Chrome, WebSocket).

, , HTTP-, - , - - , , . socket.io , , / , , , , , .

+7

Source: https://habr.com/ru/post/1568237/


All Articles