Node.js socket.io+;socket.io-redis适配器方法调用超时
我最近从Socket.io 2.x升级到了3.0.3,并将其与Socket io一起使用-redis@6.0.1. 根据原始迁移文档中的解释,我正在尝试获取所有打开的套接字的列表,包括:Node.js socket.io+;socket.io-redis适配器方法调用超时,node.js,express,socket.io,socket.io-redis,Node.js,Express,Socket.io,Socket.io Redis,我最近从Socket.io 2.x升级到了3.0.3,并将其与Socket io一起使用-redis@6.0.1. 根据原始迁移文档中的解释,我正在尝试获取所有打开的套接字的列表,包括: const ids = await io.allSockets(); 这将导致以下错误: (node:20818) UnhandledPromiseRejectionWarning: Error: timeout reached while waiting for sockets response a
const ids = await io.allSockets();
这将导致以下错误:
(node:20818) UnhandledPromiseRejectionWarning: Error: timeout reached while waiting for sockets response
at Timeout._onTimeout (/var/app/node_modules/socket.io-redis/dist/index.js:286:28)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)
(node:20818) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
请注意,只有少数客户端连接到我的开发环境,因此它试图处理太多可能导致超时的数据
当我尝试在下面运行时,我会遇到相同的错误:
const sockets = await io.of('/').adapter.sockets();
console.log(sockets); // a Set containing all the connected socket ids
const sockets = await io.of('/').adapter.sockets(new Set(['room1', 'room2']));
console.log(sockets); // a Set containing the socket ids in 'room1' or in 'room2'
// this method is also exposed by the Server instance
const sockets = io.in('room3').allSockets();
console.log(sockets); // a Set containing the socket ids in 'room3'
如果有人知道是什么导致了这个问题以及如何解决它,我们将不胜感激
最好的
H另一个socket.io服务器的早期版本(v2.x)运行在同一台服务器上,并连接到同一台Redis服务器,这就是问题的原因
使用v2.x停止其他socket.io服务器并刷新redis数据库已修复此问题。另一个socket.io服务器的早期版本(v2.x)运行在同一台服务器上,并连接到同一台redis服务器,这就是导致此问题的原因 使用v2.x停止其他socket.io服务器并刷新redis数据库已解决此问题。请参阅