Skip to content

invalid nonce error #23

@adityamertia

Description

@adityamertia

Hi,
I am getting error:
{"status": "error", "reason": "Invalid nonce", "code": "API0004"}
when i try to call 2 API calls at once. Even if i do it at interval of 100ms apart still i get this error sometimes.
As far as quoted by the library, nonce is taken care by library itself, then why should it happen.
Following is the code called in parallel:

const run = async () => {
      var balance = await bitstampBalance();
      ltcBalanceBts = parseFloat(balance.ltc_balance);
      //logger.info(`BTS Balance: LTC: ${balance.ltc_balance}, BTC: ${balance.btc_balance}`);
    };
    run().then(() => {})

Error:

(node:27758) UnhandledPromiseRejectionWarning: Error: With body: {"status": "error", "reason": "Invalid nonce", "code": "API0004"}
4|tradeCom |     at Request.request [as _callback] (/home/ec2-user/crypto_arbitrage_latest/bitstamp_bothside/node_modules/node-bitstamp/lib/Bitstamp.js:107:35)
4|tradeCom |     at Request.self.callback (/home/ec2-user/crypto_arbitrage_latest/bitstamp_bothside/node_modules/request/request.js:186:22)
4|tradeCom |     at Request.emit (events.js:160:13)
4|tradeCom |     at Request.<anonymous> (/home/ec2-user/crypto_arbitrage_latest/bitstamp_bothside/node_modules/request/request.js:1163:10)

As mentioned in the library there can still be a chance that nonce error can be generated if two calls fall at same timestamp. Does this mean there is no chance of calling 2 API in parallel in bitstamp?
If i have to call 2 APIs at once i can still do that using async.series but if the APIs are called from different parts of the code which happened to be called at once, bitstamp library should take care of nonce (is what my understanding is) which isn't happening.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions