-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
I tried to use @binance/derivatives-trading-usds-futures with http proxy.
Here is the code
import {
DERIVATIVES_TRADING_USDS_FUTURES_WS_STREAMS_PROD_URL,
DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL,
DerivativesTradingUsdsFutures,
} from "@binance/derivatives-trading-usds-futures"
const client = new DerivativesTradingUsdsFutures({
configurationRestAPI: {
basePath: DERIVATIVES_TRADING_USDS_FUTURES_REST_API_PROD_URL,
apiKey: process.env.BINANCE_API_KEY!,
apiSecret: process.env.BINANCE_SECRET_KEY!,
proxy: {
host: "192.168.0.159",
port: 3128,
protocol: "http",
},
},
})The http proxy on 192.168.0.159 is a squid proxy run with docker run --rm --name squid-container -e TZ=UTC -p 3128:3128 ubuntu/squid:5.2-22.04_beta https://hub.docker.com/r/ubuntu/squid
I can verify that the proxy is working with
❯ curl -x http://192.168.0.159:3128 https://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>
I ran the ts code above and got error (I tried nodejs as well)
❯ bun dev.ts
207 | throw new ServerError(`Server error: ${status}`, status);
208 | throw new ConnectorClientError(errorMsg);
209 | }
210 | } else {
211 | if (retries > 0 && attempt >= retries)
212 | lastError = new Error(`Request failed after ${retries} retries`);
^
error: Request failed after 3 retries
at <anonymous> (/Users/hk/Dev/bitlake/bitlake/node_modules/.pnpm/@[email protected]/node_modules/@binance/common/dist/index.mjs:212:25)
Bun v1.2.19 (macOS arm64)
The log in squid is
1753707607.465 0 192.168.0.170 NONE_NONE/400 3716 - error:invalid-request - HIER_NONE/- text/html
If I remove the proxy config, it request could go through, so it's definitely a valid API key.
The httpsAgent works though.
const proxyAgent = new HttpsProxyAgent("http://<ip>:3128")
So it's not my proxy's problem.
Metadata
Metadata
Assignees
Labels
No labels