Skip to content
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

APNS to support error-response handling(enhanced message) and re-send mechanism for performance #61

Closed
jimhorng opened this issue Apr 15, 2014 · 2 comments · Fixed by #71

Comments

@jimhorng
Copy link
Collaborator

The problem of current APNS error-response are: (reference: the problem, official doc -> The Binary Interface and Notification Format)

  • async error response (response time varies) => errors not guaranteed to be caught if wait for a fixed time
  • success do not response => cannot wait for response forever
  • async close write stream connection after error-response
  • all message sent after failed msg error are discarded, error-response and write conn close will delay => should be re-sent
  • sometimes APNS close arbitrary

From my experiment of getting error-response with enhanced message format:

  • if wait for error-response(using select.select()) with given timeout = 0s, it often get NO APNS's error-response in time,
  • when I set to 0.3s it got 90% of error-response.
    however, it's not guarantee 100% to get error-response for every failed notification, the network connection might also be a factor of delayed time.

Possible Solution

The solution suggested in the problem is to save sent notification in a queue with no timeout(or minimum), when error-response caught, pop out messages before the error one in queue (considered successfully sent), and re-sent others.
Which will not have performance concern if waiting for error-response in fixed time for each message sent, and also prevent error-response uncaught.

@hagino3000
Copy link
Contributor

I'm using PyAPNs to send 1,000,000 devices/day. And my workarounds are

  • Read error-response when queue become empty or sent 500 frames.
  • Read error-response with 0.5 sec timeout
  • If error response found, create new connection and retry sending after invalid frame.

Code is here
https://github.com/voyagegroup/apns-proxy-server/blob/065775f87dbf25f6b06f24edc73dc5de4481ad36/apns_proxy_server/worker.py#l164-209

Then my idea is 2 phase

(1) Add error handling methods for manual use

  • Add method for read error-response
  • Add method for reconnection

We can check error-respose any time.

(2) Provide automatic error handling mode

  • Save frames to retry
  • Read error-response automatically
  • Retry frames automatically

@djacobs
Copy link
Owner

djacobs commented Jun 23, 2014

@jimhorng - do you want to make a pull request?

djacobs added a commit that referenced this issue Jun 23, 2014
Add enhanced message and its corresponding error-handling, resent mechanism Fix #61.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants