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

Can't use proxies with asyncio Client #1311

Open
akoziy98 opened this issue Apr 10, 2023 · 1 comment
Open

Can't use proxies with asyncio Client #1311

akoziy98 opened this issue Apr 10, 2023 · 1 comment

Comments

@akoziy98
Copy link

Hi all!
It is not possible to adapt the work of your asynchronous part of the library to work with a proxy.

And in general, all asynchronous requests and streams do not support proxies.
The documentation suggests using the export of parameters as an env variable to solve this problem, like:

$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"

But this method didn't work for me.

I propose to add a proxy as a request parameter to the creation of an asynchronous client.

As the example. AsyncClient.create starts with using ping to binance server. This ping doesn't get any kwargs to itself.

Adding more flexibility to the asynchronous part of working with proxies can greatly help with development. Especially in those countries where the binance is blocked by the ISP, and the api keys are tied to a given api address.

@sammchardy
Copy link
Owner

A new parameter session_params was added to the AsyncClient in a recent release which allows a couple of ways of setting a proxy.

https://docs.aiohttp.org/en/stable/client_advanced.html?highlight=proxy#proxy-support

if you use the above env variables then you can include trust_env=True in session_params when creating the AsyncClient.

Otherwise you can pass the proxy directly in session_params

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

No branches or pull requests

2 participants