djacobs / PyAPNs

Python library for interacting with the Apple Push Notification service (APNs)
http://pypi.python.org/pypi/apns/
MIT License
1.22k stars 376 forks source link

Error-response doesn't work with Frames #103

Closed denisov closed 9 years ago

denisov commented 9 years ago

There is a simple test. enhanced + Frame

a = APNs(use_sandbox=True, cert_file='zzz.pem', enhanced=True)
f = Frame()
payload = Payload(alert="Hello World!", sound="default", badge=1)
f.add_item('CORRECT TOKEN', payload, 1, time.time()+3600, 10)
f.add_item('WRONG TOKEN', payload, 2, time.time()+3600, 10)
a.gateway_server.send_notification_multiple(f)

The log says me everything is fine(it is not true) . Error response worker doesn't start:

2014-12-19 18:46:32,789 - DEBUG - apns - GatewayConnection APNS connection establishing...
2014-12-19 18:46:33,508 - DEBUG - apns - GatewayConnection APNS connection established
2014-12-19 18:46:33,510 - INFO - apns -  GatewayConnection APNS connection closed

Second test. Enhanced without Frame

a = APNs(use_sandbox=True, cert_file='zzz.pem', enhanced=True)
payload = Payload(alert="Hello World!", sound="default", badge=1)
a.gateway_server.send_notification('CORRECT TOKEN', payload, 1)
a.gateway_server.send_notification('WRONG TOKEN', payload, 2)

This time I got an error from APNS, as expected:

2014-12-19 18:48:10,508 - DEBUG - apns - initialized error-response handler worker
2014-12-19 18:48:10,513 - DEBUG - apns - GatewayConnection APNS connection establishing...
2014-12-19 18:48:11,513 - DEBUG - apns - GatewayConnection APNS connection established
2014-12-19 18:48:11,705 - INFO - apns - got error-response from APNS:(8, 1)
2014-12-19 18:48:11,705 - INFO - apns -  GatewayConnection APNS connection closed
2014-12-19 18:48:11,705 - INFO - apns - resending 10 notifications to APNS
2014-12-19 18:48:11,705 - DEBUG - apns - resending notification with id:2 to APNS
2014-12-19 18:48:11,706 - DEBUG - apns - GatewayConnection APNS connection establishing...
2014-12-19 18:48:12,305 - DEBUG - apns - GatewayConnection APNS connection established
2014-12-19 18:48:42,733 - DEBUG - apns - connection idle after 30 secs
2014-12-19 18:48:42,733 - INFO - apns -  GatewayConnection APNS connection closed
2014-12-19 18:48:42,733 - DEBUG - apns - error-response handler worker closed

Question is. Does Frames can work with Enhanced mode (with error handler)?

jimhorng commented 9 years ago

Yes, it doesn't support frame in master branch, and it is already being addressed by #90 and PR #92 . FYR.

denisov commented 9 years ago

What is performance difference between frames and no-frames approaches? Does it make sense to use frames without error-response?