私のNode.JS
アプリでは、TCP接続を介してwriter
関数を再帰的に実行する必要があります。これは、どのように私はそれをやっているされていますMaxListenersExceeded socket.pipeを再帰的に使用する場合の警告
var net = require('net');
const commonConfig = require('../config.common')
var server = net.createServer(function(socket) {
let writer =() => {
socket.write(Date.now() + '\n\r')
socket.pipe(socket)
setTimeout(writer, 1000)
}
writer()
});
server.listen(commonConfig.TCP_PORT, commonConfig.TCP_ADDR);
はしかし、私は次の警告を得る:
(node:4497) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 end listeners added. Use emitter.setMaxListeners() to increase limit (node:4497) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 finish listeners added. Use emitter.setMaxListeners() to increase limit (node:4497) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 unpipe listeners added. Use emitter.setMaxListeners() to increase limit (node:4497) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 drain listeners added. Use emitter.setMaxListeners() to increase limit (node:4497) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 data listeners added. Use emitter.setMaxListeners() to increase limit (node:4497) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit (node:4497) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit
これらによって引き起こされており、どのように私は私の機能を壊すことなく、これらを解決することができますか?