我尝试在断开连接后重新连接。但是,我能够看到“尝试重新连接<> <> <> <> <> <> <> <> <>”打印,但是套接字永远无法重新连接。为什么?
socket.on('connect', () => {
console.log('socket connected ====================');
reconnectTimer && clearInterval(reconnectTimer);
dispatch(updateConnectingStatus(false));
dispatch(updateSocketStatus(true));
});
socket.on('disconnect', reason => {
console.log('socket disconnect *******************');
dispatch(updateConnectingStatus(false));
dispatch(updateSocketStatus(false));
// reconnect.
reconnectTimer = setInterval(() => {
console.log('try reconnect <><><><><><><><>');
socket.connect();
}, 1500);
});```