Comments (26)
also hyper
requires h2 <3.0
, which causes problems using other libraries that need h2>=3.0.
I'm facing an issue using hypercorn
.
from pyapns2.
Also bothered by this...
from pyapns2.
Any chance of a release?
from pyapns2.
There is some progress at #149
from pyapns2.
This is still an issue
from pyapns2.
FYI, found 2 forks where hyper was replaced with httpx:
https://github.com/pocketlabs/PyAPNs2
pocketlabs@f1220b8 doesnโt let PyAPNs2 pass its test suite.
https://github.com/karlwnw/PyAPNs2/tree/feature/httpx seems like MUCH more invasive and the last commit is still marked as WIP.
from pyapns2.
And we replaced PyAPNs2 with aioapns, which required a bit of extra work to make sure threads are properly initialised but works really well with python >= 3.8
from pyapns2.
Don't expect much to happen when you announce it's still an issue on a stale issue of an unmaintained package.
You're welcome to use my PR, which works on modern versions of Python. (I suggest forking it because I can't guarantee my branch will live forever)
#149
from pyapns2.
My conflict was with Twisted and the http2 extras installed. (Twisted[http2])
Also h2
from pyapns2.
I started looking into what it would take to port from hyper -> httpx, and it's not THAT bad, but, it does take some knowledge of the innerworkings of both packages.
Is anyone doing this? Now knowing hyper or httpx, I'm probably not the best person to do it, but, I do need it done . . . ;-)
Thoughts?
-Dave
from pyapns2.
Yes, I know, @CodeMonk specifically says CodeMonk@a1a3d59 is completely untested and dangerous, but if anybody would have means how to test it, it would be better if the patch was known.
from pyapns2.
I tested it, and declined the PR. Wasn't even close to a full solution. If anyone knows hyper or httpx, they could better evaluate how much the lift would be.
I may have some cycles to try to improve my port later.
from pyapns2.
@CodeMonk I have a proper testing environment (staging env with sandboxed apps to play with) and am willing to help, bcz we badly need it. What's the status on your PR? Why did you decline it?
from pyapns2.
FYI, found 2 forks where hyper was replaced with httpx:
https://github.com/pocketlabs/PyAPNs2
https://github.com/karlwnw/PyAPNs2
from pyapns2.
Good find, @erwan-lemonnier ! Please do share your experience here if you try either of those. I took a look at the first link and the footprint appears to be reasonably small.
from pyapns2.
https://github.com/CodeMonk/PyAPNs2/tree/feature/port-to-httpx is @CodeMonk's port.
https://github.com/chrigu/PyAPNs2/tree/feature/httpx is another port by @chrigu
Worth noting that several libraries using apns2 have switched to using https://github.com/Fatal1ty/aioapns , which only depends on h2
,pyopenssl
&pyjwt
rather than httpx
which has a large dependency tree (see https://www.wheelodex.org/projects/httpx/ ).
from pyapns2.
ping everyone , has any of these ports progressed at all?
from pyapns2.
@jayvdb I just made the parts working that I needed for my project and my port won't be developed any further.
from pyapns2.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
from pyapns2.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
from pyapns2.
This is still an issue
from pyapns2.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
from pyapns2.
Still an issue!
from pyapns2.
Yea, looks like for anyone having this issue related to django-push-notifications, there's a fix on the verge of merge: jazzband/django-push-notifications#696
from pyapns2.
When migrating to python 3.11, I basically did a self-supported implementation of an apns-client based on httpx
and certificate-authentication (pem-file) (so please, don't expect any support for this from me if this doesn't work for you).
The only thing I took from this library is the errors.py
to have a solid error-handling, the same as using this PyAPNS2-library.
https://gist.github.com/ajans/b56353067cc3ad8abbfb35c083ef4a5b
- This implementation expects a valid module-path in the variable
pem_path
to a certificate-file (pem-file) in your source-tree, adapt if you need other path-types - proxy-support:
client.py
looks for the env-variablehttps_proxy
and adds the http://-prefix if it is set without that. - connections: the httpx-client is configured to only create 1 standing connection without expiry, as the apple-documentation states, this should be enough for most use-cases. If you need more, adapt to your needs.
The method init_apns_before_retry
is meant for those cases, where e.g. the apple-service resets or discards their side of the connection. In my code using this, I annotate the _send_push_apple
method with a tenacity.retry
-annotation to use this init-method before a retry, to reset the connection into working state (1 retry is always enough to reset the connection, but you might adapt to your needs).
The send_push_apple
method itself should return the status-code PUSHSTATUS_ERROR_RETRY
if it catches a connection-issue to reset the connection:
import <your_package>.apns.client as _apns_client
@_tenacity.retry(
before_sleep=_apns_client.init_apns_before_retry,
wait=_tenacity.wait_random(min=1, max=2),
before=_tenacity.before_log(_log, _logging.WARNING),
retry=_tenacity.retry_if_result(lambda value: value == PUSHSTATUS_ERROR_RETRY),
stop=_tenacity.stop_after_attempt(2),
retry_error_callback=_give_up_retry,
)
def _send_push_apple(
request,
push_token,
apple_payload,
apple_custom,
dev,
):
push_token = push_token_schema.validate(push_token)
# Send a notification
status = PUSHSTATUS_OK
try:
_log.debug(
"trying to send apple-push %s to push-token %s",
str(apple_payload),
push_token,
)
_apns_client.send_notification(push_token, apple_payload, apple_custom, dev)
# ... don't forget to catch and handle APNS-errors like "BadDeviceToken" and "Unregistered" ...
except (
BrokenPipeError,
_ssl.SSLError,
_httpx.RequestError,
) as exc:
# another retryable error happened
status = PUSHSTATUS_ERROR_RETRY
_log.error(
"apple-push with %s to push-token %s failed with retryable error %s",
str(apple_payload),
push_token,
str(exc),
)
return status
# noinspection PyUnusedLocal
def _give_up_retry(retry_state): # pylint: disable=unused-argument
_log.error("This was the last attempt, giving up")
return PUSHSTATUS_ERROR
Maybe this code-snippet might not be easy to integrate into your project, so maybe it would be better to migrate the PyAPNs2-code here or in a fork to use something like this.
But since I don't have the time or energy to do it myself and don't want to constantly ask for support here, I thought it might be good idea to share these snippets with you, since PyAPNS2 helped me a lot before with the initial implementation with older python-versions and I wanted to give something back that might be helpful with these stuck dependencies.
from pyapns2.
I started a project https://pypi.org/project/compat-fork-apns2/ aiming to update this project for newer versions of Python. Unfortunately, I don't have enough time and expertise to finish switching away from hyper, but if someone else is interested in contributing code or helping to maintain the fork, please let me know at compat-fork#3.
from pyapns2.
Related Issues (20)
- Where's extra flag? HOT 2
- threading.Thread.setDaemon has been deprecated in favor of setting daemon attribute directly in Python 3.10 HOT 1
- How to get the response? My notification works for some device tokens but fails for other. HOT 1
- apns2 0.7.2 requires PyJWT<2.0.0,>=1.4.0, but you have pyjwt 2.1.0 which is incompatible. HOT 25
- DeviceTokenNotForTopic for voip push HOT 1
- SSL error HOT 1
- The library dependency hyper seems not compatible with 3.10 HOT 2
- send_notification_batch method discards same token result during compose batch response HOT 1
- Fail to push notification HOT 1
- AttributeError: 'PosixPath' object has no attribute 'create_connection'
- Python 3.10 compatibility HOT 3
- ssl.SSLZeroReturnError HOT 7
- Compatibility with Mac M1 (Python 3.10) HOT 3
- Vulnerability in PyJWT HOT 2
- How is set apns-id? HOT 1
- Failing to find Algorithm 'ES256' in aws lambda HOT 1
- ssl.SSLError: [SSL: BAD_LENGTH] bad length HOT 4
- Current status of project HOT 1
- Provided examples do not work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyapns2.