craysiii / binance

API Wrapper for the Binance cryptocurrency exchange written in Ruby.
MIT License
97 stars 79 forks source link

WebSocket Stream Reconnect #9

Closed toddsampson closed 6 years ago

toddsampson commented 6 years ago

According to Binance's documentation, "A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark" It would be fantastic if there was either a built-in auto-reconnect in the API wrapper or example code in the readme on how to properly auto-reconnect to the stream.

P.S. Thanks for writing this API wrapper. It has been fantastic!

craysiii commented 6 years ago

Hey @toddsampson - Thanks for the kind words!

This issue will be addressed this weekend. I am still debating if I want to write the auto-reconnect myself, or if it should be left up to the developer to do so. With the gem, I am taking this approach: The library should be making a little decisions as possible for the developer. This is why I simply have you pass your API and secret keys instead of forcing you to put them into environment variables; I don't want to force your hand in using .env or figaro. The same sort of applies here. I don't want to force what I think is the correct way to handle auto-connect on you all. There might be some additional code that you'd like to add.

The plan currently is just to write a really good example on using WebSockets. Someone else and I discussed this in issue #8 and it's been sitting on the back burner for a few days. Expect to see something by End of Sunday GMT-8.

toddsampson commented 6 years ago

Fantastic! Thanks for the update.

Can't believe I missed #8. I did a serach for "reconnect" on the project but should have looked closer.

craysiii commented 6 years ago

No worries! I’m going to go ahead and close this issue when I get home so we can all look to #8 for when this is resolved.