Socket.io和React-native seTimeout警告

时间:2017-11-04 20:51:09

标签: android react-native socket.io

我按照此链接设置了socket.io with react:https://medium.com/dailyjs/combining-react-with-socket-io-for-real-time-goodness-d26168429a34

已安装的软件包

  • socket.io-client:2.0.4
  • react-native-cli:2.0.1
  • react-native:0.48.3

现在,我在Android模拟器上启动应用时收到以下警告: Emulator

我已尝试使用以下代码:

import openSocket from 'socket.io-client';
const options = {
  pingTimeout: 3000,
  transports: ['websocket'],
  allowUpgrades: false,
  cookie: false
};
const socket = openSocket(url, options);

1 个答案:

答案 0 :(得分:1)

您还需要将{pingTimeout:30000}添加到将socket.io绑定到服务器的位置。

var io = socketio(server, {pingTimeout: 30000})