bitfinexcom / bitfinex-api-go

BITFINEX Go trading API - Bitcoin, Litecoin, and Ether exchange
https://www.bitfinex.com/
MIT License
309 stars 220 forks source link

Channel ping reconnect #93

Closed brobits closed 6 years ago

brobits commented 6 years ago

passes all existing tests, added new UT in reconnect_test.go to demonstrate channel heartbeat timeouts. I think server heartbeats are 2.5 seconds apart. as a rule of thumb, I use 3/2 * interval for timeout windows, so I've set the default timeout window to 2.5*3/2= ~3.7s. the timeout window is a lower bound on how quickly the client API can detect a logically dead channel and attempt to reconnect websocket.

there is no failover fallback plan in place yet. ideally a 1st chance heartbeat timeout will simply unsubscribe & resubscribe the channel. this opens extra edge cases which I'm putting on the backburner until we can meet our other deadlines