-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Users receiving duplicate notifications #123
Comments
|
I experience the the same situation. and my code like:
and user received hundreds of duplicated messages. |
Sorry for the delay. Here is my code:
Note that initially, I set had been setting the identifier to 0, since I didn't care about identifying dropped messages. But then after looking at the PyAPNs source, I saw that the identifier was used internally to figure out which messages to resend, so I could definitely see this being the reason for repeat notifications (IMO, this should be make clearer in the documentation). Additionally, I realized I can't used non-enhanced mode, because then I have to wait a few seconds between notifications to see if it was successful or not. Or else I will loose a bunch of notifications I send behind a failed one. Right? Basically I just want to send a lot of notifications, but I don't care about re-trying failed ones. It's really annoying that Apple drops the connection on a failed push. I just want it to silently ignore them. |
Yes, you are right, while the document might states clearer, the current statement is
yes, in non-enhanced mode APNS will not send you error-response when failed.
So you should still use enhanced mode, the re-send is NOT re-trying the failed ones, it is resending all notification sent between the last "failed" notification and the one before APNS drops the connection, which are all dropped silently. |
I guess I know the reason why this happens:
question: I feel that I should read through the source code to make sure no duplicated messages will be send. Thanks :) |
Yes, it should be, otherwise please fire a bug :)
It's a good intention, however as my current knowledge, it can only check identifier's uniqueness on runtime during sending lots of message and might not trustworthy, and, it might not help much. Please provide good suggestion or PR for discussion :) |
Follow @jimhorng instruction to create random identifier. However, there is another problem, APNS sometimes returns identifier 0, then cause duplicated messages again. So I temporarily fix by adding "identifier > 0" condition. Wonder if there is a better fix for this?
|
@ngonpham , |
@jimhorng Yes, always return in my case. (8, 8, 0) are returned for command, status, identifier = unpack(ERROR_RESPONSE_FORMAT, buff) |
@ngonpham excited to see some more data here! May I ask how you're testing/reproducing this? Are you using the sandbox or live server? |
@ibushong I'm using live, here is the code
|
Is that running inside of a loop? Or you are able to reproduce it with only one push? |
It ran in a loop @ibushong |
We ran into the same problem recently.
I think it is already set in the code: So: |
@vhquang |
I thought about set |
I haven't looked deeply at this yet, but it feels like something that documentation could improve, no? |
I just had this problem with enhanced=True and unique identifier (I set identifier with django model's id field) ..... sad thing is I can't figure out why it happened... I am using 3d40f97 commit. |
As far as I remember, enhanced mode send messages out in batch, and require each message to have unique identifier. When you have use set that identifier with django's model, it is possible that by the time you send out the message, your model is not saved yet. Thus you did not have the id by the time the message sent out. Try saving your model first. |
I'm not sure how this is possible because I thought Apple prevented this...but for some reason, after implementing this library, users are receiving multiple instances of push notifications.
In my first implementation, I looped over a few thousand users, using the enhanced setting. A bunch of our users got hundreds of repeating notifications and had to uninstall the app to stop it. Not a good experience. Looking through the logs, it appears that when PyAPNs went back to re-send dropped notifications (due to an invalid token earlier on), it resends notifications that were already sent. Now this is probably due to some implementation error of mine instead of a library issue. But everything seems pretty straightforward, so I'm not sure what could be causing this.
Since then, I've broken up our mass pushes into smaller chucks, but still some users report getting 2-3 duplicate notifications.
Has anyone else experienced this? Any tips for debugging this? (Hard to reproduce for debugging because I need a large audience and that only happens in production)
I guess I could always switch to the non-enhanced versions right? That would definitely prevent this issue, with the tradeoff of taking longer (due to the blocking socket).
The text was updated successfully, but these errors were encountered: