Git Product home page Git Product logo

Comments (26)

levy42 avatar levy42 commented on September 12, 2024 6

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.

thierryba avatar thierryba commented on September 12, 2024 4

Also bothered by this...

from pyapns2.

daveisfera avatar daveisfera commented on September 12, 2024 4

Any chance of a release?

from pyapns2.

jayvdb avatar jayvdb commented on September 12, 2024 4

There is some progress at #149

from pyapns2.

daveisfera avatar daveisfera commented on September 12, 2024 3

This is still an issue

from pyapns2.

mcepl avatar mcepl commented on September 12, 2024 2

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

https://github.com/karlwnw/PyAPNs2/tree/feature/httpx seems like MUCH more invasive and the last commit is still marked as WIP.

from pyapns2.

erwan-lemonnier avatar erwan-lemonnier commented on September 12, 2024 1

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.

salty-horse avatar salty-horse commented on September 12, 2024 1

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.

kevindice avatar kevindice commented on September 12, 2024

My conflict was with Twisted and the http2 extras installed. (Twisted[http2])
Also h2

from pyapns2.

CodeMonk avatar CodeMonk commented on September 12, 2024

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.

mcepl avatar mcepl commented on September 12, 2024

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.

CodeMonk avatar CodeMonk commented on September 12, 2024

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.

erwan-lemonnier avatar erwan-lemonnier commented on September 12, 2024

@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.

erwan-lemonnier avatar erwan-lemonnier commented on September 12, 2024

FYI, found 2 forks where hyper was replaced with httpx:
https://github.com/pocketlabs/PyAPNs2
https://github.com/karlwnw/PyAPNs2

from pyapns2.

whardeman avatar whardeman commented on September 12, 2024

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.

jayvdb avatar jayvdb commented on September 12, 2024

ping @karlwnw & @kitdesai

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.

jayvdb avatar jayvdb commented on September 12, 2024

ping everyone , has any of these ports progressed at all?

from pyapns2.

chrigu avatar chrigu commented on September 12, 2024

@jayvdb I just made the parts working that I needed for my project and my port won't be developed any further.

from pyapns2.

github-actions avatar github-actions commented on September 12, 2024

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.

github-actions avatar github-actions commented on September 12, 2024

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.

daveisfera avatar daveisfera commented on September 12, 2024

This is still an issue

from pyapns2.

github-actions avatar github-actions commented on September 12, 2024

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.

ssyberg avatar ssyberg commented on September 12, 2024

Still an issue!

from pyapns2.

ssyberg avatar ssyberg commented on September 12, 2024

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.

ajans avatar ajans commented on September 12, 2024

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

  1. 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
  2. proxy-support: client.py looks for the env-variable https_proxy and adds the http://-prefix if it is set without that.
  3. 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.

JelleZijlstra avatar JelleZijlstra commented on September 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.