socket.io redis 和内存泄漏
我的 socket.io 版本是 [email protected] 和 [电子邮件受保护]。 我在 Windows 上。
在某些地方,我看到问题已得到解决。我想我正在使用最新的 socket.io 版本。 什么是emitter.setMaxListeners()以及在哪里可以设置它?
(node) warning: possible EventEmitter memory leak detected. 11 listeners added.
Use emitter.setMaxListeners() to increase limit.
Trace:
at RedisClient.<anonymous> (events.js:133:17)
at Socket.<anonymous> (c:\HTML5\LIKEPREF\test\server\server.js:576:18)
at Socket.$emit (events.js:67:17)
at SocketNamespace.handlePacket (C:\Personal\software\nodejs\NODE\node_modul
es\socket.io\lib\namespace.js:335:22)
at Manager.onClientMessage (C:\Personal\software\nodejs\NODE\node_modules\so
cket.io\lib\manager.js:459:38)
at WebSocket.onMessage (C:\Personal\software\nodejs\NODE\node_modules\socket
.io\lib\transport.js:387:20)
at Parser.<anonymous> (C:\Personal\software\nodejs\NODE\node_modules\socket.
io\lib\transports\websocket\hybi-16.js:40:10)
at Parser.emit (events.js:67:17)
at C:\Personal\software\nodejs\NODE\node_modules\socket.io\lib\transports\we
bsocket\hybi-16.js:286:16
at Parser.expectHandler (C:\Personal\software\nodejs\NODE\node_modules\socke
t.io\lib\transports\websocket\hybi-16.js:297:15)
我正在使用 redis pubsub,当我订阅 redis 时,它会抛出此警告。
My socket.io version is [email protected] and [email protected].
I am on Windows.
In some places, I have seen that the issue is solved. I suppose I am using the latest socket.io version.
what is emitter.setMaxListeners() and where can I set it ?
(node) warning: possible EventEmitter memory leak detected. 11 listeners added.
Use emitter.setMaxListeners() to increase limit.
Trace:
at RedisClient.<anonymous> (events.js:133:17)
at Socket.<anonymous> (c:\HTML5\LIKEPREF\test\server\server.js:576:18)
at Socket.$emit (events.js:67:17)
at SocketNamespace.handlePacket (C:\Personal\software\nodejs\NODE\node_modul
es\socket.io\lib\namespace.js:335:22)
at Manager.onClientMessage (C:\Personal\software\nodejs\NODE\node_modules\so
cket.io\lib\manager.js:459:38)
at WebSocket.onMessage (C:\Personal\software\nodejs\NODE\node_modules\socket
.io\lib\transport.js:387:20)
at Parser.<anonymous> (C:\Personal\software\nodejs\NODE\node_modules\socket.
io\lib\transports\websocket\hybi-16.js:40:10)
at Parser.emit (events.js:67:17)
at C:\Personal\software\nodejs\NODE\node_modules\socket.io\lib\transports\we
bsocket\hybi-16.js:286:16
at Parser.expectHandler (C:\Personal\software\nodejs\NODE\node_modules\socke
t.io\lib\transports\websocket\hybi-16.js:297:15)
I am using redis pubsub and when i am subscribing to redis, at that point it throws up this warning.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个与此相关的已知问题。看起来几个月前就已经修复了。最简单的解决方法是将最大侦听器设置为 0,这将消除实际限制。所以它看起来像这样:
您可以在这里找到完整的讨论:https://github.com/LearnBoost/ socket.io/issues/520
There is a known issue associated with this. Looks like it was patched several months ago. The easiest fix is to set the maximum listeners to 0 which will remove the actual limit. So it would look something like this:
You can find the full discussion here: https://github.com/LearnBoost/socket.io/issues/520