Closed s-a closed 4 years ago
Hi, the underlying connection pool to Apples servers is what’s keeping the process running. We maintain these connections for performance reasons but I should definitely provide a close() method to disconnect.
In the mean time, is there anything wrong with calling process.exit() at the end of your script? I’ve found that to be a lot more reliable anyway, instead of tracking down every dep that might have a connection open somewhere.
Thank you for fast response. Well I plan to implement your module into an express server . So process exit is not possible. Also Unit Tests will be quite impossible. Seems after some time your pool closes. However if you point me to the right code place I can try to send a PR tomorrow.
Try calling client._clients.destroy()
. That calls destroy on the underlying tarn pool and should kill all connections. Note if you do that you will not be able to send any more push notifications from that client and will need to instantiate a new one
Also note that destroy()
returns a promise so you may need to await client._clients.destroy()
depending on the context
Seems to work. Will try a real APN today. Thank you for your support!
I added client.destroy()
to v8.4 https://github.com/AndrewBarba/apns2/releases/tag/8.4.0
Hi, my node process it still running after send call. How to close connection ?