codedge-llc / pigeon

iOS and Android push notifications for Elixir
https://hex.pm/packages/pigeon
MIT License
645 stars 145 forks source link

APNS worker receiving unhandled :closed messages #66

Open asgoel opened 7 years ago

asgoel commented 7 years ago

Seems like kadabra is sending :closed messages to the APNS worker (which theoretically shouldn't be happening with the ping...), and the APNS worker can't handle them. For now I've custom forked this to basically just shutdown (and thus auto-restart) the worker when this happens. Are there any drawbacks to doing this? Will I lose messages?

hpopp commented 7 years ago

State isn't preserved across restarts, so callbacks would be lost.

Each push gets mapped to a stream ID on the worker, and when the http2 connection reconnects, the current stream ID gets reset to 1. Even if the old callbacks were persisted, there would be no way to map them to the new session.

I think push handling needs to be rewritten to always set an apns-id on the notification when one isn't defined. We could store the worker state in ETS and resend queued messages on restart.