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

Running alongside node-binance-api gives ECONNREFUSED 127.0.0.1:443 #78

Open
alimohyudin opened this issue Mar 5, 2022 · 2 comments
Open

Comments

@alimohyudin
Copy link

alimohyudin commented Mar 5, 2022

Everything works best until I added Binance Api support for my application.

Error I get:

RequestError: connect ECONNREFUSED 127.0.0.1:443
    at ClientRequest.<anonymous> (/server-bot/node_modules/got/dist/source/core/index.js:956:111)
    at Object.onceWrapper (node:events:510:26)
    at ClientRequest.emit (node:events:402:35)
    at ClientRequest.origin.emit (/server-bot/node_modules/@szmarczak/http-timer/dist/source/index.js:43:20)
    at TLSSocket.socketErrorListener (node:_http_client:447:9)
    at TLSSocket.emit (node:events:390:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1146:16) {
  code: 'ECONNREFUSED',
  timings: {
    start: 1646464300686,
    socket: 1646464300686,
    lookup: 1646464300686,
    connect: undefined,
    secureConnect: undefined,
    upload: undefined,
    response: undefined,
    end: undefined,
    error: 1646464300687,
    abort: undefined,
    phases: {
      wait: 0,
      dns: 0,
      tcp: undefined,
      tls: undefined,
      request: undefined,
      firstByte: undefined,
      download: undefined,
      total: 1
    }
  }
}

If I remove node-binance-api from code it works just fine.

What should be the patch I need to do to make it work?

Thanks

@BobWassermann
Copy link

I'm running into the same issue. Seems to work locally, but break once I deploy.

@alimohyudin
Copy link
Author

alimohyudin commented Mar 13, 2022

I'm running into the same issue. Seems to work locally, but break once I deploy.

The issue was with got module kraken.js is using.
I solved this by replacing got with axios inside kraken.js of this module.

//const got    = require('got');
const axios = require('axios');

...

const rawRequest = async(url, headers, data, timeout) => {
    // Set custom User-Agent string
    headers['User-Agent'] = 'Kraken Javascript API Client';

    const options = { headers, timeout };

    Object.assign(options, {
        method: 'POST',
        body: qs.stringify(data),
    });

    // const { body } = await got(url, options);
    // const response = JSON.parse(body);
    let body = await axios.post(url, qs.stringify(data), options);

    let myresponse = JSON.stringify(body.data);
    // console.log("start");
    // console.log(myresponse);
    // console.log("end");


    const response = JSON.parse(myresponse);

    if (response.error && response.error.length) {
        const error = response.error
            .filter((e) => e.startsWith('E'))
            .map((e) => e.substr(1));

        if (!error.length) {
            throw new Error("Kraken API returned an unknown error");
        }

        throw new Error(error.join(', '));
    }

    return response;
};

You can ask me if you get any error, will be happy to help you. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants