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

invalid nonce error #23

Open
adityamertia opened this issue Mar 11, 2018 · 0 comments
Open

invalid nonce error #23

adityamertia opened this issue Mar 11, 2018 · 0 comments

Comments

@adityamertia
Copy link
Contributor

adityamertia commented Mar 11, 2018

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.

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

1 participant