Socket.io redis and memory leak

My version of socket.io is socket.io@0.8.7 and redis@0.7.1. I am on Windows.

In some places, I saw that the problem was resolved. I assume I am using the latest version of socket.io. What is emitter.setMaxListeners () and where can I install 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 subscribe to redis, at that moment it triggers this warning.

+4
source share
1 answer

There is a known issue with this. It looks like it was fixed a few months ago. The simplest fix is ​​to set the maximum listeners to 0, which remove the actual limit. Therefore, it looks something like this:

 this.sub = redis.createClient(opts.redisSub.port, opts.redisSub.host, opts.redisSub); this.sub.setMaxListeners(0); 

Here you can find the full discussion: https://github.com/LearnBoost/socket.io/issues/520

+8
source

Source: https://habr.com/ru/post/1396769/


All Articles