Closed sbat closed 6 years ago
Hi @sbat, from the issue you referenced it looks like it's an open issue with node-apn?
I think this happens because you always create a new connection and never close it.
From the node-apn
readme:
You should only create one
Provider
per-process for each certificate/key pair you have. You do not need to create a newProvider
for each notification. If you are only sending notifications to one app then there is no need for more than oneProvider
.If you are constantly creating
Provider
instances in your app, make sure to callProvider.shutdown()
when you are done with each provider to release its resources and memory.
So something like this would help:
const connection = new apn.Provider(settings.apn);
return connection.send(message, regIds)
.then((response) => {
/* ... */
connection.shutdown();
return resumed;
})
.catch((error) => {
connection.shutdown();
throw error;
})
But as mentioned in #47 it would be better to reuse the connection and offer a push.shutdown()
or something like this.
Is there a way to manually shutdown the connection to the provider?
When will #55 be merged and released?
Looks like the pull request doesn't really fix the issue apparently. Do yourself a favour everyone and update to Node 8.8.1+... I have released a package that eliminates the memory leak issue.
Merging #55 as a quick fix for the memory leak issue. Will look into changing the implementation to only use one Provider instance, if feasible.
Fixed after merge of #55
I get this warning:
The warning comes from the APN Module: https://github.com/node-apn/node-apn/issues/518
See someone else this error? Have someone a solution?