djacobs / PyAPNs

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

In enhanced mode, connection will enter bad state and stop sending notification after connection idles for more than 2 hours #94

Closed jimhorng closed 9 years ago

jimhorng commented 10 years ago

The connection might be broken but the library is not awared, and error-response worker might hang and cause connection not function properly, then, send notification with the same connection will be blocked.

jimhorng commented 10 years ago

fixed by #78

aabilio commented 10 years ago

Could #78 FIX the following error? ->

I have and app (deployed at AWS EB) that is using this project to send push notifications to Apple's devices. It works all okay the first time when I deploy the app, but a while later all notifications stop working and I can't log the problem.. If I redeploy the app again (OR reboot EC2 instance) all works well again the first.. 30 minutes?

I don't know how to log the problem and it's getting me crazy :S

jimhorng commented 10 years ago

@aabilio , I guess the problem is very similar to mine, you may check netstat -ant | grep 2195 to see if connection to apns are gone or not in ESTABLISHED. If so, it's very likely the same cause which can be fixed by this PR #78 .

aabilio commented 10 years ago

netstat -ant | grep 2195 shows nothing (after this time when the notifications are not working). I going to use your fork to check if solves my problem. Thanks.

jimhorng commented 10 years ago

@aabilio , Great, please kindly let me know if it solved your problem or not, thanks :)

jimhorng commented 9 years ago

@aabilio , any good or bad news on this fix? thanks :)

aabilio commented 9 years ago

I had not had time to try. I hope to try it tomorrow ;)

Abilio Almeida (@aabilio https://twitter.com/aabilio) Co-founder, CTO & Developer at WeKnow Creative SL (@weknow_creative https://twitter.com/weknow_creative) http://weknowcreative.co Founder at http://www.pydowntv.com

2014-10-13 8:16 GMT+02:00 Jim Horng notifications@github.com:

@aabilio https://github.com/aabilio , any good or bad news on this fix? thanks :)

— Reply to this email directly or view it on GitHub https://github.com/djacobs/PyAPNs/issues/94#issuecomment-58850056.

thejeff77 commented 9 years ago

jimhorng, I pulled your modified code, and it appears to fix this issue. Good job. I believe this should be high priority for a merge. I also hope that the next major version added to pypi happens soon, and includes this change. I look forward to an update on this situation. Thanks again!

jimhorng commented 9 years ago

@jblayney Thanks for your trying, since @djacobs is the owner of this project, could you help to suggest him to merge this #78? Thanks a lot :D

aabilio commented 9 years ago

I just started testing this right now. In a few hours I'll tell you the results ;)

djacobs commented 9 years ago

Thanks.

jimhorng commented 9 years ago

@aabilio may I know your test result, if it passed, then we can close this issue since #78 is merged :)

aabilio commented 9 years ago

I've been testing these days and now it seems that everything works fine

Abilio Almeida (@aabilio https://twitter.com/aabilio) Co-founder, CTO & Developer at WeKnow Creative SL (@weknow_creative https://twitter.com/weknow_creative) http://weknowcreative.co Founder at http://www.pydowntv.com

2014-10-24 4:51 GMT+02:00 Jim Horng notifications@github.com:

@aabilio https://github.com/aabilio may I know your test result, if it passed, then we can close this issue since #78 https://github.com/djacobs/PyAPNs/pull/78 is merged :)

— Reply to this email directly or view it on GitHub https://github.com/djacobs/PyAPNs/issues/94#issuecomment-60338468.

jimhorng commented 9 years ago

nice, good to hear that, then I'l close this issue now.

ghost commented 9 years ago

Still experiencing this. First message is sent successfully but subsequent ones fail with:

[Errno 22] Invalid argument
Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 310, in post
    self.run_from_request()
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 305, in run_from_request
    run(self.request.body)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 147, in run
    return func(*args, **kwds)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/deferred/deferred.py", line 190, in invoke_member
    return getattr(obj, membername)(*args, **kwargs)
  File "/base/data/home/apps/s~yida-kelonye/1.381243078546549010/server/models.py", line 765, in _apn
    APNS.gateway_server.send_notification_multiple(frame)
  File "/base/data/home/apps/s~yida-kelonye/1.381243078546549010/server/lib/apns/__init__.py", line 549, in send_notification_multiple
    return self.write(frame.get_frame())
  File "/base/data/home/apps/s~yida-kelonye/1.381243078546549010/server/lib/apns/__init__.py", line 260, in write
    _, wlist, _ = select.select([], [self._connection()], [], WAIT_WRITE_TIMEOUT_SEC)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py", line 493, in select
    raise _SystemExceptionFromAppError(e)
error: [Errno 22] Invalid argument

This is in GAE btw.

jimhorng commented 9 years ago

@kelonye As your log shows, you are using enhanced mode with frames, which is NOT currently supported, see #90, there's patch already but not merged to 'master' branch yet.

ghost commented 9 years ago

Thanks mate!