gekko icon indicating copy to clipboard operation
gekko copied to clipboard

Nonce is too small Error. When trying to use bitfinex exchange.

Open sad8c opened this issue 9 years ago • 16 comments

Just starting gekko node gekko Then i see some advices and then gekko stops with error:

Gekko encountered an error and can't continue

Error:

Error: Nonce is too small.
    at Request._callback (/home/ubuntu/workspace/gekko/node_modules/bitfinex-api-node/rest.js:68:23)
    at Request.self.callback (/home/ubuntu/workspace/gekko/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:192:7)
    at Request.<anonymous> (/home/ubuntu/workspace/gekko/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:189:7)
    at IncomingMessage.<anonymous> (/home/ubuntu/workspace/gekko/node_modules/request/request.js:1001:12)
    at Object.onceWrapper (events.js:291:19)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:186:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9) '\n\n'

Meta debug info:

Gekko version: v0.3.4
Nodejs version: v7.5.0

If i use log.debug in rest.js file (in bitfinex-api-node module):

function rest(key, secret, nonceGenerator) {
    this.url = "https://api.bitfinex.com";
    this.version = 'v1';
    this.key = key;
    this.secret = secret;
    this.nonce = new Date().getTime();
    this._nonce = typeof nonceGenerator === "function" ? nonceGenerator : function () {
        //noinspection JSPotentiallyInvalidUsageOfThis
        log.debug(this.nonce);
        return ++this.nonce;
    };
}

i see nonces logged in console, and see another error:

2017-02-21 16:39:10 (DEBUG):    1487695150056
2017-02-21 16:39:10 (DEBUG):    1487695150057
2017-02-21 16:39:10 (DEBUG):    1487695150058
2017-02-21 16:39:10 (DEBUG):    1487695150059
2017-02-21 16:39:10 (DEBUG):    1487695150060
2017-02-21 16:39:10 (DEBUG):    1487695150061
2017-02-21 16:39:10 (DEBUG):    1487695150062
2017-02-21 16:39:10 (DEBUG):    1487695150063
2017-02-21 16:39:10 (DEBUG):    1487695150064
2017-02-21 16:39:10 (DEBUG):    1487695150065
2017-02-21 16:39:10 (DEBUG):    1487695150066
2017-02-21 16:39:10 (DEBUG):    1487695150067
2017-02-21 16:39:10 (DEBUG):    1487695150068
2017-02-21 16:39:10 (DEBUG):    1487695150069
2017-02-21 16:39:10 (DEBUG):    1487695150070
2017-02-21 16:39:10 (DEBUG):    1487695150071
2017-02-21 16:39:10 (DEBUG):    1487695150072
2017-02-21 16:39:10 (DEBUG):    1487695150073
2017-02-21 16:39:10 (DEBUG):    { type: 'exchange',
  currency: 'btc',
  amount: '1.0',
  available: '1.0' }
/home/ubuntu/workspace/gekko/plugins/trader/portfolioManager.js:110
  return this.getFund(fund).amount;
                           ^

TypeError: Cannot read property 'amount' of undefined
    at Manager.getBalance (/home/ubuntu/workspace/gekko/plugins/trader/portfolioManager.js:110:28)
    at Manager.bound [as getBalance] (/home/ubuntu/workspace/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at Manager.act (/home/ubuntu/workspace/gekko/plugins/trader/portfolioManager.js:138:23)
    at bound (/home/ubuntu/workspace/gekko/node_modules/lodash/dist/lodash.js:729:21)
    at /home/ubuntu/workspace/gekko/node_modules/async/lib/async.js:232:13
    at /home/ubuntu/workspace/gekko/node_modules/async/lib/async.js:142:25
    at /home/ubuntu/workspace/gekko/node_modules/async/lib/async.js:229:17
    at /home/ubuntu/workspace/gekko/node_modules/async/lib/async.js:556:34
    at Manager.<anonymous> (/home/ubuntu/workspace/gekko/plugins/trader/portfolioManager.js:76:7)
    at /home/ubuntu/workspace/gekko/exchanges/bitfinex.js:56:5
    at Request._callback (/home/ubuntu/workspace/gekko/node_modules/bitfinex-api-node/rest.js:70:16)
    at Request.self.callback (/home/ubuntu/workspace/gekko/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:192:7)
    at Request.<anonymous> (/home/ubuntu/workspace/gekko/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:189:7)
    at IncomingMessage.<anonymous> (/home/ubuntu/workspace/gekko/node_modules/request/request.js:1001:12)
    at Object.onceWrapper (events.js:291:19)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:186:7)
    at endReadableNT (_stream_readable.js:974:12)

sad8c avatar Feb 21 '17 16:02 sad8c

Sorry, it's not bound. I have Nonce error even if i log this:

2017-02-21 16:44:43 (DEBUG):    1487695483017
2017-02-21 16:44:43 (DEBUG):    1487695483018
2017-02-21 16:44:43 (DEBUG):    1487695483019
2017-02-21 16:44:43 (DEBUG):    1487695483020
2017-02-21 16:44:43 (DEBUG):    1487695483021
2017-02-21 16:44:43 (DEBUG):    1487695483022
2017-02-21 16:44:43 (DEBUG):    1487695483023
2017-02-21 16:44:43 (DEBUG):    1487695483024
2017-02-21 16:44:43 (DEBUG):    1487695483025
2017-02-21 16:44:43 (DEBUG):    1487695483026
2017-02-21 16:44:43 (DEBUG):    1487695483027
2017-02-21 16:44:43 (DEBUG):    1487695483028
2017-02-21 16:44:43 (DEBUG):    1487695483029
2017-02-21 16:44:43 (DEBUG):    1487695483030


Gekko encountered an error and can't continue

Error:

Error: Nonce is too small.
    at Request._callback (/home/ubuntu/workspace/gekko/node_modules/bitfinex-api-node/rest.js:68:23)
    at Request.self.callback (/home/ubuntu/workspace/gekko/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:192:7)
    at Request.<anonymous> (/home/ubuntu/workspace/gekko/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:189:7)
    at IncomingMessage.<anonymous> (/home/ubuntu/workspace/gekko/node_modules/request/request.js:1001:12)
    at Object.onceWrapper (events.js:291:19)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:186:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9) '\n\n'

Meta debug info:

Gekko version: v0.3.4
Nodejs version: v7.5.0

sad8c avatar Feb 21 '17 16:02 sad8c

I've noticed that logging nonces a really strange. In unixtime it is like that: 1487695483030 = Wed, 12 Mar 49113 17:17:10 GMT

sad8c avatar Feb 21 '17 17:02 sad8c

I think "Nonce too small" can be because any same process is running twice. But which process?...

sad8c avatar Feb 21 '17 20:02 sad8c

I can take a look at this when I have time. Its very possible the bfx npm module is outdated and would need to be rewritten.

http://docs.bitfinex.com/v1/docs/rest-auth

xhad avatar Feb 23 '17 07:02 xhad

Getting the same error with Poloniex.

thegamecat avatar Mar 07 '17 17:03 thegamecat

same problem on the Bitfinex

Rudimo avatar Mar 23 '17 08:03 Rudimo

Bitfinex problem

x0rium avatar Mar 23 '17 08:03 x0rium

Still getting this on poloniex

thegamecat avatar Apr 25 '17 21:04 thegamecat

I had this error when I ran gekko in a virtual machine on Windows 7. In my case it turned out to be time drift.

generalectric avatar Apr 25 '17 21:04 generalectric

This is on ubuntu 16.04 and:

Nonce must be greater than 1905332886555001. You provided 149315522139600.

thegamecat avatar Apr 25 '17 21:04 thegamecat

Is anyone else getting this issue on Poloniex?

thegamecat avatar Apr 26 '17 08:04 thegamecat

@thegamecat please open a seperate issue for poloniex, this is definitely not the same problem!

askmike avatar Apr 26 '17 08:04 askmike

I have worked on updating the codebase for bitfinex (as part of #737), in my testing I am unable to reproduce. I am closing this because I assume this is not an issue anymore, it it is please comment here :)

askmike avatar Jul 02 '17 16:07 askmike

I have just had the same problem ... I have remove old api key/secret. Create a new one and now it s work.

ghost avatar Apr 01 '18 00:04 ghost

I have this problem too on my local. On VPS working fine. Created new API doesnt help.

@askmike I can give You access to my local with anydesk to fix it if You want.

xFFFFF avatar Apr 14 '18 15:04 xFFFFF

Same problem on Poloniex. Error: Nonce must be greater than 152510833507500. You provided 152510832809100

halflive-1 avatar May 01 '18 10:05 halflive-1