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

Subscribe ticker for a lot of symbols crashes #435

Open
MauriPastorini opened this issue Nov 17, 2018 · 2 comments
Open

Subscribe ticker for a lot of symbols crashes #435

MauriPastorini opened this issue Nov 17, 2018 · 2 comments

Comments

@MauriPastorini
Copy link

Hi, using websockets when I try to subscribe to a lot of symbols, the library crashes instantaneously.
What can I do please?

Here is my code:

const timeBetweenRequest = 10 * 1000;

const BFX = require("bitfinex-api-node");
const options = {
  ws: {
    autoReconnect: true,
    seqAudit: true,
    packetWDDelay: timeBetweenRequest
  }
};
const bfx = new BFX(options);

const start = symbols => {
  const ws = bfx.ws(2, { transform: false });

  ws.on("open", () => {
    console.log("open");
    for (let x = 0; x < symbols.length; x++) {
      var element = symbols[x];
      ws.subscribeTicker(element);
    }
  });

  ws.onTicker({}, (ticker, info) => {
    console.log("Info: ", info);
    console.log("Ticker: ", ticker);
  });

  ws.open();
};

start(["Pair1", "Pair2", "Pair3", "...."])

Error:

events.js:188
      throw err;
      ^

Error: Unhandled "error" event. ([object Object])
    at WSv2.emit (events.js:186:19)
    at WSv2._handleErrorEvent (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\lib\transports\ws2.js:1045:10)
    at WSv2._handleEventMessage (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\lib\transports\ws2.js:994:19)
    at WSv2._onWSMessage (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\lib\transports\ws2.js:550:12)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at Receiver._receiver.onmessage (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\node_modules\ws\lib\WebSocket.js:141:47)
    at Receiver.dataMessage (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\node_modules\ws\lib\Receiver.js:389:14)
    at Receiver.getData (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\node_modules\ws\lib\Receiver.js:330:12)
    at Receiver.startLoop (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\node_modules\ws\lib\Receiver.js:165:16)
    at Receiver.add (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\node_modules\ws\lib\Receiver.js:139:10)
    at TLSSocket._ultron.on (G:\Mis Documentos\Proyectos Freelance\Arbitrage\ArbitrageRepo\node_modules\bitfinex-api-node\node_modules\ws\lib\WebSocket.js:138:22)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at TLSSocket.Readable.push (_stream_readable.js:208:10)
    at TLSWrap.onread (net.js:594:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start_bitfinex_job: `node jobs/bitfinex`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start_bitfinex_job script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Mauri-Laptop\AppData\Roaming\npm-cache\_logs\2018-11-17T22_14_56_566Z-debug.log

Regards

@f3rno
Copy link
Contributor

f3rno commented Nov 19, 2018

@MauriPastorini can you add an error listener to see what the error actually is? Code:

ws.on('error', (err) => console.log(`error: ${err.message}`))

@fieldfoxWim
Copy link

What version are you using?
Because 18 days ago the models were changed breaking this module.
Can you test if it works with v2.0.0?

references:

Cheers

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

3 participants