Marfusios/bitfinex-client-websocket

Reconnect not working

andrzej-suwala opened this issue · 2 comments

Hi,

Thanks for all your good work.
I've compiled your console sample, and reconnecting is not working.
Please take a look at screenshot
https://ibb.co/gYDdUc

I've run the app, disconnected internet cable, waited 30 sec. and reconnected the cable.
Internet is working, but the app didn't reconnect.

Hello,

it seems to me, that you are not resubscribing to channels, hence you don't get any new messages and it invokes a new reconnecting.

You should handle info message and authentication message and then resubscribe, example:

client.Streams.InfoStream.Subscribe(info =>
{
    Log.Information($"Reconnection happened, Message: {info.Msg}, Version: {info.Version}");
    client.Authenticate(API_KEY, API_SECRET);
});

client.Streams.AuthenticationStream.Subscribe(auth =>
{                    
    Log.Information($"Authenticated: {auth.IsAuthenticated}");

    client.Send(new TradesSubscribeRequest("BTC/USD"));
    client.Send(new CandlesSubscribeRequest("BTC/USD", BitfinexTimeFrame.OneMinute));
    client.Send(new BookSubscribeRequest("BTC/USD", BitfinexPrecision.P0, BitfinexFrequency.TwoSecDelay));
});

communicator.Start().Wait();

Thank you, I'll try it.