bitcore-node icon indicating copy to clipboard operation
bitcore-node copied to clipboard

Error from socket.io

Open jpochyla opened this issue 9 years ago • 6 comments

After cca a day of running bitcore-node 3.1.0 we get:

...
[2016-08-05T09:51:26.624Z] info: 79.42.190.240 web socket subscribe:
bitcoind/hashblock
[2016-08-05T09:51:26.624Z] info: 79.42.190.240 subscribe:
bitcoind/hashblock total: 1408863
[2016-08-05T09:53:18.383Z] error: uncaught exception: [RangeError:
Maximum call stack size exceeded]
[2016-08-05T09:53:18.403Z] error: RangeError: Maximum call stack size
exceeded
    at Socket.flush
(/home/bitcore/src/bitcore-node/node_modules/socket.io/node_modules/engine.io/lib/socket.js:413:32)
    at emitNone (events.js:72:20)
    at WebSocket.emit (events.js:166:7)
    at
/home/bitcore/src/bitcore-node/node_modules/socket.io/node_modules/engine.io/lib/transports/websocket.js:109:14
    at afterWrite (_stream_writable.js:346:3)
    at nextTickCallbackWithManyArgs (node.js:463:18)
    at process._tickCallback (node.js:361:17)

It seems this is a socket.io problem, is that right? Thanks a lot!

jpochyla avatar Aug 09 '16 15:08 jpochyla

Bitcore crashes like this every three hours or so for me. Looks like having Insight homepage open is enough for bitcore to crash, which is pretty unusable.

Any idea why it crashes?

slush0 avatar Aug 12 '16 13:08 slush0

I've seen a similar error once or twice when starting a node that hasn't been running for awhile, I suspect it has to do with a large number of events coming from transactions when many blocks are being connected.

braydonf avatar Aug 12 '16 14:08 braydonf

We need a reproducible test case to fix this.

braydonf avatar Aug 12 '16 14:08 braydonf

This happen randomly; yesterday our server crashed 7-times, today it is "just" once (yet). I assume that finding reproducible test case is the biggest part of fixing it...

slush0 avatar Aug 15 '16 12:08 slush0

We found out the reason behind this - by a programming mistake, we called, from the web side, socket.emit('subscribe', 'bitcoind/hashblock') about 1.000.000 times, from the same web application, which created 1.000.000 subscribers, which is probably what caused the crash.

In the log:

[2016-08-05T09:51:26.624Z] info: 79.42.190.240 subscribe: bitcoind/hashblock total: 1408863

We will fix it in the web app, but there are questions:

  • what are the limits of subscribers?
  • shouldn't there be some limits per IP? it's very easy to make the server crash by abusing this

karelbilek avatar Sep 06 '16 13:09 karelbilek

I will note that this triggered over a long time where the app was still running in the background for 24 hours, sending 10 subscribe requests every second.

When I now tried to do a small testcase, that will "bombard" bitcore node with subscribe requests every 10 ms, it crashes on memory issues. (So sort of a DDoS.); but that seems like a different issue

karelbilek avatar Sep 06 '16 13:09 karelbilek