Binance node api connection issue

22 views Asked by At

I am encountering an issue with the Binance API Node Connector where I am getting inconsistent results. Sometimes I receive the correct output like { mins: 5, price: '61547.44293040', closeTime: 1709275080153 }, but most of the time, I encounter an error indicated by ECONNRESET. Code Snippet: javascript

` const { Spot } = require("@binance/connector");

 const apiKey = "YOUR_API_KEY";
 const apiSecret = "YOUR_API_SECRET";
 const client = new Spot(apiKey, apiSecret);

 async function main() { 
 try {
 const result = await client.avgPrice('BTCUSDT');
 console.log(result.data);
 } catch (e) {
 console.log(e);
 main();
 }
 }

 main();

Error Message: Error: read ECONNRESET at Axios.request (D:\programming hero\Next-Level Web Dev\practice-project\bot\bottest\Server-Template\node_modules\axios\dist\node\axios.cjs:3877:41) ... errno: -4077, code: 'ECONNRESET', syscall: 'read'`

0

There are 0 answers