node-binance-api icon indicating copy to clipboard operation
node-binance-api copied to clipboard

Proxy module is needed when you a in a country wehere web is blocked

Open jzyzxx opened this issue 4 years ago • 9 comments

Proxy module is needed,especially the ws proxy.Now this is my proxy for http:

const Binance =require("node-binance-api");
const binance = new Binance().options({
  proxy:{
      host:"127.0.0.1",
      port:"49751"
  },
  APIKEY: '````',
  APISECRET: '````'
});

But i dont know how to deal with the ws proxy for websocket?

jzyzxx avatar Aug 06 '21 08:08 jzyzxx

hi @jzyzxx How could you deal with proxy with future feature?

_binance = new BinanceApi().options({
        proxy:{
            host:"p.webshare.io",
            port:"80",
            auth: "userName:password"
        },
        'APIKEY': apiKey,
        'APISECRET': apiSecret,
        'test': true,
        useServerTime: true
    });

The error return tunneling socket could not be established, statusCode=407. Am I config correctly?

longlch avatar Aug 08 '21 08:08 longlch

hi @jzyzxx How could you deal with proxy with future feature?

_binance = new BinanceApi().options({
        proxy:{
            host:"p.webshare.io",
            port:"80",
            auth: "userName:password"
        },
        'APIKEY': apiKey,
        'APISECRET': apiSecret,
        'test': true,
        useServerTime: true
    });

The error return tunneling socket could not be established, statusCode=407. Am I config correctly?

The proxy did not work for ws connectionn,maybe you shoud get tips from the author

jzyzxx avatar Aug 08 '21 08:08 jzyzxx

I can config successfully in http with username and password.

_binance = new BinanceApi().options({
        proxy:{
            host:"p.webshare.io",
            port:"80",
            auth: {
                username: "yourUserName",
                password: "yourPassword"
            },
        },
        'APIKEY': apiKey,
        'APISECRET': apiSecret,
        'test': true,
        useServerTime: true
    });

longlch avatar Aug 08 '21 09:08 longlch

I can config successfully in http with username and password.

_binance = new BinanceApi().options({
        proxy:{
            host:"p.webshare.io",
            port:"80",
            auth: {
                username: "yourUserName",
                password: "yourPassword"
            },
        },
        'APIKEY': apiKey,
        'APISECRET': apiSecret,
        'test': true,
        useServerTime: true
    });

But it dit not work for ws connection,the log indicated that the connection timeout.

jzyzxx avatar Aug 09 '21 01:08 jzyzxx

I can config successfully in http with username and password.

_binance = new BinanceApi().options({
        proxy:{
            host:"p.webshare.io",
            port:"80",
            auth: {
                username: "yourUserName",
                password: "yourPassword"
            },
        },
        'APIKEY': apiKey,
        'APISECRET': apiSecret,
        'test': true,
        useServerTime: true
    });

But it dit not work for ws connection,the log indicated that the connection timeout.

There are my logs:

[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]
[
  'Futures WebSocket error: btcusdt@miniTicker (ETIMEDOUT) connect ETIMEDOUT 31.13.69.160:443'
]
[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]
[
  'Futures WebSocket error: btcusdt@miniTicker (ETIMEDOUT) connect ETIMEDOUT 111.243.214.169:443'
]
[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]

jzyzxx avatar Aug 09 '21 01:08 jzyzxx

I can config successfully in http with username and password.

_binance = new BinanceApi().options({
        proxy:{
            host:"p.webshare.io",
            port:"80",
            auth: {
                username: "yourUserName",
                password: "yourPassword"
            },
        },
        'APIKEY': apiKey,
        'APISECRET': apiSecret,
        'test': true,
        useServerTime: true
    });

But it dit not work for ws connection,the log indicated that the connection timeout.

There are my logs:

[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]
[
  'Futures WebSocket error: btcusdt@miniTicker (ETIMEDOUT) connect ETIMEDOUT 31.13.69.160:443'
]
[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]
[
  'Futures WebSocket error: btcusdt@miniTicker (ETIMEDOUT) connect ETIMEDOUT 111.243.214.169:443'
]
[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]

bump, i have same problem

neody avatar Jan 17 '22 23:01 neody

I can config successfully in http with username and password.

_binance = new BinanceApi().options({
        proxy:{
            host:"p.webshare.io",
            port:"80",
            auth: {
                username: "yourUserName",
                password: "yourPassword"
            },
        },
        'APIKEY': apiKey,
        'APISECRET': apiSecret,
        'test': true,
        useServerTime: true
    });

But it dit not work for ws connection,the log indicated that the connection timeout.

There are my logs:

[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]
[
  'Futures WebSocket error: btcusdt@miniTicker (ETIMEDOUT) connect ETIMEDOUT 31.13.69.160:443'
]
[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]
[
  'Futures WebSocket error: btcusdt@miniTicker (ETIMEDOUT) connect ETIMEDOUT 111.243.214.169:443'
]
[ 'Futures WebSocket closed: btcusdt@miniTicker (1006)' ]
[ 'Futures WebSocket reconnecting: btcusdt@miniTicker...' ]

bump, i have same problem

I met the same problem too

jzyzxx avatar Jan 18 '22 01:01 jzyzxx

seems there is no way to use proxy option in websocket connection, only process.env.https_proxy and process.env.socks_proxy are accepted.

https://github.com/jaggedsoft/node-binance-api/blob/950d773a5f2c3a61c6e29b53e3af57594921a239/node-binance-api.js#L681-L701

liesauer avatar May 18 '23 13:05 liesauer

can't use custom proxyAgent either.

import Binance from 'node-binance-api';
import tunnel from "tunnel";

const proxy = tunnel.httpsOverHttp({
    proxy: {
        host: 'localhost',
        port: 8080,
        proxyAuth: "",
    },
});

// doesn't work
const binance = new Binance().options({
    proxy: proxy,
});

liesauer avatar May 18 '23 13:05 liesauer