Stack Exchange
When using socket.io-client in react-native, it will automatically disconnect after 30 seconds
Version list：
｛
  "react": "16.3.1",
  "react-native": "0.55.4"
  "socket.io-client": "^2.1.1"
｝

The code in app.js in the client：
.....
import io from 'socket.io-client/dist/socket.io';
const server = "https://xxx.xxx.xxx.xxx/";
let socket = io(server, {
  'reconnection'        : true,
  'reconnectionDelay'   : 500,
  'reconnectionAttempts': Infinity,
  'transports'          : ['websocket']
});

socket.on('connect', () => {
  console.log("connect");
});
......

nodeJS server code
....
const io  = require('socket.io')(httpsServer);
....
let clients = {};
let count = 0;

io.on('connection', function (socket) {
  clients[socket.id] = socket;

  socket.emit("all message", 'data'); //send successfully

  socket.on("disconnect",() => {
    console.log("disconnect"); // Disconnect after 30 seconds
    delete clients[socket.id];
  })
});


setInterval(() => {
  count+=Object.keys(clients).length;
  console.log(count);  // will stop at count value 30
},1000)

30 seconds after the connection is successful，The socket.io-client in the client react-native will be automatically disconnected.

i have the same problem did you solve this

Hi, were you able to solve this problem?
