I send push notications using node apn.
occur problem of emitter.setMaxListeners() about sending push on 10,000 users.
but not occur problem about sending push on 1,000 users.
how fix this problem.
warning message :
(node:17804) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit
code
const server = new Hapi.Server();
server.connection({port: 3000});
...
server.register([{
...
}], (err) => {
if (err) {
throw err;
}
server.start((err) => {
if (err) {
throw err;
}
console.log(`Server running at : ${server.info.uri}`);
});
});
server.route({
method: 'POST',
path: '/push',
handler: function(request, reply) {
...
var notification = new apn.Notification() ;
notification.badge = count ;
notification.sound = "default" ;
notification.alert = message ;
notification.topic = toping ;
...
//here tokens 10,000 counts
apn_sender.send(notification, tokens).then((result) => {
var res = {
success : result.sent.length,
failed : result.failed.length
} ;
return reply(res) ;
}) ;
...
}
});