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

Bitfinex Disconnections-Reconnections #25

Closed
ciottied opened this issue Jun 7, 2018 · 14 comments
Closed

Bitfinex Disconnections-Reconnections #25

ciottied opened this issue Jun 7, 2018 · 14 comments

Comments

@ciottied
Copy link

ciottied commented Jun 7, 2018

Bitfinex.NET connects and reconnects to Bitfinex at least once per day, sometime many times a day.
I get it because I log the events BitfinexSocketClient.ConnectionLost and BitfinexSocketClient.ConnectionRestored.

Sometimes Bitfinex.NET reconnects but the candle subscription (opened at startup with BitfinexSocketClient.SubscribeToCandleUpdates ) is not restored.

I thought about a timer to detect if data is still arriving and, if not, close-reopen connection from scratch.
Is there a better way to deal with the issue ?

P.S.: my machine is in a datacenter with 99.9 connectivity SLA, so connections/reconnections are probably originated from Bitfinex endpoint and inherent to their service.

@JKorf
Copy link
Owner

JKorf commented Jun 11, 2018

Hi, do you have/can you provide debug logging of when this happens? By design Bitfinex.NET should resubscribe the subscriptions that were running when the disconnect happened. If this doesn't happen (sometimes), then that's a bug.

@ciottied
Copy link
Author

ciottied commented Jun 11, 2018 via email

@ciottied
Copy link
Author

Hi Jan.

In the Activity log You can see a connection/disconnection logged the day 14 at 19:14:25 - 19:14:28 .
In the candle events log You see that the last 60 min candle event received is at 19:00:00 and then no more events were received.

What I suspect is that connection/disconnection causes the loss of candle subscription.
The version I'm testing was compiled on 12/5/2018 with last available Bitfinex.NET library.
Bitfinex.dll properties says version 1.0.0.0

Best regards.

edc

20180614ActivityLog.txt
20180614CandleEvents.txt

@ciottied
Copy link
Author

ciottied commented Jun 20, 2018

Right Now Another example:

I logged:

20/06/2018 16.40.38.025 
------+++------
Bitfinex Connection Lost
------+++------
20/06/2018 16.40.41.143 
------+++------
Bitfinex Connection Restored
------+++------
20/06/2018 16.41.14.850 
------+++------
Bitfinex Connection Lost
------+++------
20/06/2018 16.41.17.115 
------+++------
Bitfinex Connection Restored
------+++------

And Subscriptions (at least candle subscriptions than in my app fires all the events) are gone.
The 17:00:00 Candle was not logged.

@JKorf
Copy link
Owner

JKorf commented Jun 22, 2018

Hi, I've refactored some of the reconnection handling in the new version (v1.0.13), could you see if this fixes your problems?

@ciottied
Copy link
Author

Hi.
I went mad several hours testing some changes that I made and nothing worked.
Then I reverted to 1.012 and everything began to work again.
Apparently 1.013 is broken and candle subscription does not return any data.

@JKorf
Copy link
Owner

JKorf commented Jun 22, 2018

Sorry to hear that, I'll look into it tomorow

@JKorf
Copy link
Owner

JKorf commented Jun 25, 2018

I assume you called the subscribe functions before the Start function in the socket client? I found a bug introduced in version 1.0.13 which caused the subscriptions only to work if called AFTER the start method. This is fixed in 1.0.14, please try that.

@ciottied
Copy link
Author

Yes, exactly.
I literally copied your example that makes subscriptions before starting socket.

Thank You.

@JKorf
Copy link
Owner

JKorf commented Jun 26, 2018

Can you confirm that the subscriptions still work after reconnecting?

@ciottied
Copy link
Author

Tested.
It works.

Thank You.

@ciottied
Copy link
Author

ciottied commented Jul 9, 2018

Update:
My system reconnects if it doesn't receive candle updates for 300 secs and, after 3 weeks of 24/7 operation, I can confirm that is working like a charm.
Reconnecting works.

@JKorf
Copy link
Owner

JKorf commented Jul 10, 2018

Great. Do you still have 300s timeouts though? The websocket should reconnect after 15 seconds of not receiving any data, so I would expect that wouldn't be necessary. (server send a heartbeat message every x seconds, which is handled internally in the library)

@ciottied
Copy link
Author

Oh Yes.
many connection/disconnections per day, 300 secs timeout and reconnection at least once per day.
See screenshot.

image

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

2 participants