appfeel / node-pushnotifications

Push notifications for GCM, APNS, MPNS, AMZ (automatic detection from device token)
MIT License
534 stars 126 forks source link

Memory leaks with APN token authentication #89

Closed amangeot closed 6 years ago

amangeot commented 6 years ago

Hello, I'm running a job every hour that sends weather alerts to our users when necessary. When using token instead of certificates for APN authentication, the memory is not released after running the job:

image

Here are my settings for token authentication. This was pushed in production where I wrote "Token" on the screenshot above. "Restart" simply is a restart of the server.

  apn: {
    token: {
      key: './src/pushNotifications/certificates/APNsAuthKey_KEYID.p8',
      keyId: 'KEYID',
      teamId: 'TEAMID',
      production: __PROD__,
    },
  },

This is running v1.0.21, on Amazon Linux AMI release 2017.03, with node v6.11.2

I'm not sure if I'm misusing the package or there are some memory leaks.

Thank you for releasing this package,

alex-friedl commented 6 years ago

Hello @amangeot , it could be related to #70. Btw. your APN settings are not quite correct, due to a mistake I made in the README, which has since been corrected.

The production key should be outside the token object.

apn: {
    token: {
      key: './src/pushNotifications/certificates/APNsAuthKey_KEYID.p8',
      keyId: 'KEYID',
      teamId: 'TEAMID',
    },
   production: __PROD__,
  }
amangeot commented 6 years ago

Thank you, I'll update my settings.

Regarding node-apn v3 I'm not in a big hurry to update my node versions as we run multiple projects and all sort of unexpected things may happen though that's one way to go!

amangeot commented 6 years ago

I ran the script on my machine, and the script will not exit after finishing. I received these errors which I suspect come from this package but I also have a database connection using pg-promise:

(node:13712) Warning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit
(node:13712) Warning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit

Do you know if we should force closing the application with process.exit(0) or something similar to kill / close the push notifications tooling?

miqmago commented 6 years ago

Duplicate of https://github.com/appfeel/node-pushnotifications/issues/70, please reopen if it's not.

Possible solutions:

Waiting for https://github.com/node-apn/node-apn/issues/518 to be solved...

vibhor1997a commented 5 years ago

I am facing the exact issue in version 2.2.0. (node:12020) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit (node:12020) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit (node:12020) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit (node:12020) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit (node:12020) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit (node:12020) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 wakeup listeners added. Use emitter.setMaxListeners() to increase limit

miqmago commented 5 years ago

Please reffer to #70