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

Error when config axios request #342

Open
phongtran2309 opened this issue May 7, 2024 · 1 comment
Open

Error when config axios request #342

phongtran2309 opened this issue May 7, 2024 · 1 comment
Labels
question General question / more info needed user error Usage/implementation error, not a bug

Comments

@phongtran2309
Copy link

const { RestClientV5 } = require('bybit-api');

const client = new RestClientV5(
{
testnet: true,
key: key,
secret: secret,
},
{
proxy: {
host: host,
port: port,
auth: {
username: username,
password: password,
},
},
},
);
client.submitOrder({
category: 'spot',
symbol: 'ETHUSDT',
side: 'Buy',
orderType: 'Market',
qty: '0.1',
})
.then((response) => {
console.log(JSON.stringify(response, null, 2));
})
.catch((error) => {
console.error(error);
});
i got error "Error: Client network socket disconnected before secure TLS connection was established" when i make a api call

"headers: Object [AxiosHeaders] {
Accept: 'application/json, text/plain, /',
'Content-Type': 'application/json',
'X-BAPI-SIGN-TYPE': '2',
'X-BAPI-API-KEY': 'vTxZJiHCNDBCBIzaYe',
'X-BAPI-TIMESTAMP': '1715069550287',
'X-BAPI-SIGN': 'a52550de4c44fcdfb30d251a769973d515e4acc0c4618ea38f6713e69dd46a52',
'X-BAPI-RECV-WINDOW': '5000',
'x-referer': 'bybitapinode',
'User-Agent': 'axios/1.6.8',
'Content-Length': '84',
'Accept-Encoding': 'gzip, compress, deflate, br'
},"

@tiagosiebler
Copy link
Owner

Proxying is handled via axios (which is used for all HTTP request building in my SDKs). There's a few ways to configure proxies, and the correct way depends on the proxy you're trying to use. Ideally the provider of your proxy can explain how to use it / what kind of proxy it is. Typically this method will work for most HTTP/HTTPS proxies:
https://github.com/tiagosiebler/bybit-api/blob/master/examples/rest-v5-proxies.ts#L20-L32

In some cases, some HTTP/HTTPS proxies will only work by using a proxy agent such as HttpsProxyAgent:
https://github.com/tiagosiebler/bybit-api/blob/master/examples/rest-v5-proxies2.ts#L41-L42

If you're using a SOCKS or SOCKS5 proxy, there's also a SocksProxyAgent on npm.

@tiagosiebler tiagosiebler added question General question / more info needed user error Usage/implementation error, not a bug labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General question / more info needed user error Usage/implementation error, not a bug
Projects
None yet
Development

No branches or pull requests

2 participants