How to fetchOrderbook using Proxy

See original GitHub issue

OS: Windows Server 2019 Datacenter Programming Language version: Node.js 15.3.0 CCXT version: 1.49.98 Exchange: Binance and All Exchanges Method: exchange.fetchOrderBook()

Hello!

I am trying to fetchOrderBook using the proxy method but are not successfull when doing the request. The proxy IP I use must use: username, password, proxyIP and port which I have just confirmed are a working proxyIP in another C# application. (I have changed those for this post as seen)

I am not sure if I miss something of how to set this up?

Thank you!

This is the code I am trying to use:

        var HttpsProxyAgent = require('https-proxy-agent');
        
        var username = 'myusername';
        var password = 'mypassword';
        var proxyip = '209.197.291.180';
        var port = '9279';
        var proxy = 'https://' + username + ':' + password + '@' + proxyip + ':' + port; 
        var agent = new HttpsProxyAgent(proxy);

        const exchange = new ccxt.binance({ enableRateLimit: true, agent, 'timeout': 10000 });
        exchange.verbose = true;

        const orderbook = await exchange.fetchOrderBook("BTC/USDT", 5);
        console.log(orderbook);

This is the error response I get: (with exchange.verbose = true)

C:\myproject\node_modules\ccxt\js\base\Exchange.js:401
throw new ExchangeNotAvailable ([ this.id, method, url, e.type, e.message ].join (' '))
                                  ^

ExchangeNotAvailable: binance GET https://api.binance.com/api/v3/exchangeInfo system request to https://api.binance.com/api/v3/exchangeInfo failed, reason: write EPROTO 148:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_record.c:332:

    at C:\myproject\node_modules\ccxt\js\base\Exchange.js:401:35
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async timeout (C:\myproject\node_modules\ccxt\js\base\functions\time.js:195:24)
    at async binance.request (C:\myproject\node_modules\ccxt\js\binance.js:3145:26)
    at async binance.fetchMarkets (C:\myproject\node_modules\ccxt\js\binance.js:828:26)
    at async binance.loadMarketsHelper (C:\myproject\node_modules\ccxt\js\base\Exchange.js:670:25)
    at async binance.fetchOrderBook (C:\myproject\node_modules\ccxt\js\binance.js:1273:9)
    at async testorderbooks (C:\myproject\functions.js:1116:27)
    at async testCommandStation (C:\myproject\functions.js:1079:5) {
  constructor: [class ExchangeNotAvailable extends NetworkError]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jackpotcitycocommented, Feb 4, 2022

I think I did find the problem. It seems that the https:// is wrong, it should be http://. The proxy itself should be accessed by HTTP and not HTTPS. So I changed it to this and now it was possible to return the orderbook.

var proxy = 'http://' + username + ':' + password + '@' + proxyip + ':' + port;

Thank you very much for your help and now I have the newest version of ccxt also.

Thank you!

1reaction
kroitorcommented, Feb 3, 2022

@jackpotcityco pardon, i confused it with python, my bad. For node, please, upgrade your version of CCXT first (the most recent version is 1.72+). Let us know if that does not help

Read more comments on GitHub >

github_iconTop Results From Across the Web

support of IP/socks/http proxy in node version of the ccxt library
I am looking for the ways to implement proxying the IP to send concurrent fetchOrderBook requests in node code (using promise.all). you guided ......
Read more >
Manual — ccxt 2.4.71 documentation
This is the list of exchanges in CCXT Pro with support for WebSockets APIs. ... fetchOrderBook (symbol, limit) // do something or react...
Read more >
how to connect proxies in the ccxt library? - Stack Overflow
I try to call a function (sell/buy, whatever) through a proxy, but it gives an error. What am I doing wrong?
Read more >
ccxt使用笔记 - 知乎专栏
Here's an overview of base exchange properties with values added for example: ... dictionary of dictionaries (markets) by id 'proxy': ...
Read more >
Change proxy settings on Mac - Apple Support
Configure proxy server settings automatically. Automatic proxy configuration. Use a proxy auto-configuration (PAC) file. Enter the address of the PAC file in ...
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