我按照此链接设置了socket.io with react:https://medium.com/dailyjs/combining-react-with-socket-io-for-real-time-goodness-d26168429a34
已安装的软件包
我已尝试使用以下代码:
import openSocket from 'socket.io-client';
const options = {
pingTimeout: 3000,
transports: ['websocket'],
allowUpgrades: false,
cookie: false
};
const socket = openSocket(url, options);
答案 0 :(得分:1)
您还需要将{pingTimeout:30000}添加到将socket.io绑定到服务器的位置。
var io = socketio(server, {pingTimeout: 30000})