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

FCM API Credential refresh mechanism doesn't support HTTP proxies and blocks the event loop #371

Closed
reivilibre opened this issue May 13, 2024 · 5 comments · Fixed by #372
Labels

Comments

@reivilibre
Copy link
Contributor

title says it all: it doesn't look like we support HTTP proxies here and given no await I suspect this also blocks the event loop:

credentials.refresh(request)

@reivilibre reivilibre added the bug label May 13, 2024
@reivilibre
Copy link
Contributor Author

reivilibre commented May 13, 2024

aiohttp supports proxies: https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support

as does HTTPX, which sounds like it could be the next big thing in Python, or maybe that's just some inflated hype — would need consideration: https://www.python-httpx.org/

(Either of these would probably be preferable to us hacking our own CONNECT proxy support into Twisted and asyncio using two similar but different bits of code. Realistically it doesn't make that much sense for us to be using Twisted in Sygnal anymore)

@MatMaul
Copy link
Contributor

MatMaul commented May 13, 2024

The google-auth lib seems to support a custom urllib3 pool: https://googleapis.dev/python/google-auth/latest/user-guide.html#urllib3

To my understanding we can replace an urllib3 PoolManager by a ProxyManager: https://urllib3.readthedocs.io/en/stable/advanced-usage.html#proxies

I guess it would be the straightest way to support a proxy here, what do you think ?

@MatMaul
Copy link
Contributor

MatMaul commented May 13, 2024

Oh urllib3 is blocking, but it seems we are using the requests backend for now, which is also blocking, hence the fact that there is no await I think.

We can also customize the requests Session, and use a proxy there: https://docs.python-requests.org/en/latest/user/advanced/#proxies

@MatMaul
Copy link
Contributor

MatMaul commented May 13, 2024

google-auth has an aiohttp backend even if it seems undocumented.

And it seems that it can support a custom Session which easily supports a proxy, so we may have an easy-ish async way forward.

@MatMaul
Copy link
Contributor

MatMaul commented May 14, 2024

To be clear so we don't double the work, we need proxy support on our deploy so I am currently working on that, I should be able to send a PR this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants