Closed throughnothing closed 9 years ago
A few notes:
pool.disconnect()
goes through the keys of_connectedPeers
: https://github.com/bitpay/bitcore-p2p/blob/master/lib/pool.js#L134 (if it doesn't exist it wouldn't be called)._removeConnectedPeer
is called is when a peer disconnects, so if it's not in the _connectedPeers
object there might be another problem (e.g. a peer is not in _connectedPeers when it should be).@braydonf that was my concern. This 'fix' in this PR is probably just masking the real issue.
Also I believe a peer will emit "disconnect" if there isn't "ready" event, perhaps there is a way to may this happen more quickly using a timeout?
Edit: Looks like disconnect happens on socket end or if the buffer is above the max: https://github.com/bitpay/bitcore-p2p/blob/master/lib/peer.js#L120
We found an issue where disconnect was called twice and was likely the root of the issue, and is now fixed: https://github.com/bitpay/bitcore-p2p/commit/f8578ff114b2911d9b1dfe95b857d2d964928200
Thank you!
I'm not entirely sure this is the right solution, but I've gotten this error working on my SPV client.
I set a timeout to
peer.disconnect()
a peer if I don't receive averack
message within 3 seconds, to weed out slow peers from my pool (not sure if that's a good approach or not), but when I call thepeer.disconnect()
on the timeout, it seems to bubble up to this. My change alleviates that problem, but not sure it's the correct fix or not as I haven't traced through what exactly is going on yet.