最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Node.js如何设置MaxListeners()

运维笔记admin15浏览0评论

Node.js如何设置MaxListeners()

Node.js如何设置MaxListeners()

我以前从未使用过node.js。但是按照here中的步骤进行solr安全代理。一切正常,但它给了我这个警告。我知道我必须设置最大侦听器,但是不知道如何以及在哪里做。请帮助我。

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at addListener (events.js:160:15)
    at /home/abc/node_modules/solr-security-proxy/node_modules/http-proxy/lib/node-http-proxy/routing-proxy.js:63:27
    at Array.forEach (native)
    at null.<anonymous> (/home/abc/node_modules/solr-security-proxy/node_modules/http-proxy/lib/node-http-proxy/routing-proxy.js:62:33)
    at emit (events.js:98:17)
    at addListener (events.js:138:10)
    at Array.0 (/home/abc/node_modules/solr-security-proxy/solr-security-proxy.js:69:13)
    at Server.handler (/home/abc/node_modules/solr-security-proxy/node_modules/http-proxy/lib/node-http-proxy.js:175:40)
    at Server.emit (events.js:98:17)
    at HTTPParser.parser.onIncoming (http.js:2164:12)
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
    at addListener (events.js:160:15)
    at Array.0 (/home/abc/node_modules/solr-security-proxy/solr-security-proxy.js:69:13)
    at Server.handler (/home/abc/node_modules/solr-security-proxy/node_modules/http-proxy/lib/node-http-proxy.js:175:40)
    at Server.emit (events.js:98:17)
    at HTTPParser.parser.onIncoming (http.js:2164:12)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:152:23)
    at Socket.socket.ondata (http.js:2022:22)
    at TCP.onread (net.js:528:27)
回答如下:

您在调用setMaxListeners(或setMaxListeners)的同一对象上调用addListener,该对象将是addListener

但是,如果您确实确实存在发射器内存泄漏(而不是碰巧需要11个侦​​听器,而不再需要),那么您需要从根本上解决该问题-提高限制将无济于事。

参见:on

发布评论

评论列表(0)

  1. 暂无评论