question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aiohttp request with proxy params in ccxt.async

See original GitHub issue

Hello. I want to fetch orderbooks from bittrex using ccxt.async through my proxy server. I know that fetch_order_book uses aiohttp module in it, and I want to pass my proxy address to aiohttp.ClientSession().get() as a parameter, as shown below.

async with aiohttp.ClientSession() as session:
    async with session.get("http://python.org",
                           proxy="http://some.proxy.com") as resp:
        print(resp.status)

So, I think I need to override fetch_order_book(). How do I get through this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
dhmk815commented, Oct 20, 2017

@kroitor Thank you 😃

1reaction
kroitorcommented, Jun 19, 2019

@owneroxxor using an external session + socks connector could work:

pip install aiohttp_socks

The example code could look close to this:

import ccxt.async_support as ccxt
import aiohttp
import aiohttp_socks

connector = aiohttp_socks.SocksConnector.from_url('socks5://user:password@127.0.0.1:1080')
session = aiohttp.ClientSession(connector=connector)

exchange = ccxt.binance({
    'session': session,
    'enableRateLimit': True,
    # ...
})

# ...

Make sure you await session.close() when you don’t need it anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Client Usage — aiohttp 3.8.3 documentation
Create the session first, use the instance for performing HTTP requests and initiating ... async def on_request_start( session, trace_config_ctx, params): ...
Read more >
Exchanges — ccxt 2.4.71 documentation
An example of a proxy string is 'http://cors-anywhere.herokuapp.com/' . The absolute exchange endpoint URL is appended to this string before sending the HTTP ......
Read more >
ccxt-dev/ccxt - Gitter
Hola @kroitor, I have a question regarding the python async exchange class. ... asyncio.ensure_future(self.session.close(), loop=self.asyncio_loop).
Read more >
aiohttp ssl certificate_verify_failed - You.com | The AI Search ...
The CA file is working with cURL, Python Requests, but not aiohttp, ... ClientSession() as session: async with session.get(url, params=params) as resp: ...
Read more >
ccxt Documentation - Read the Docs
https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support. # This is the setting you should be using with async version of ccxt ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found