Marfusios / bitfinex-client-websocket

🛠️ C# client for Bitfinex & Ethfinex websocket API version 2.0
Apache License 2.0
55 stars 38 forks source link

Anyone get cut off after about 50 minutes? #4

Closed dendle closed 6 years ago

dendle commented 6 years ago

Hello All,

I am using this library in a console app, and am using the sample.

I keep getting the "No message received after 10 minutes, hard reset" message after about 50 minutes of activity.

Anyone else seeing this?

Cheers, Matt

Marfusios commented 6 years ago

Hello,

thanks for the message. I found the mistake, which caused the issue, it should be fixed now (version >= 0.0.8). I wanted to provide an optional possibility for user/developer to adjust native .NET websocket client (ClientWebSocket), so it was reusing the instance (really bad idea..), now it's solved by factory method. Example:

var wsClientFactory = () => new ClientWebSocket()
            {
                Options =
                {
                    KeepAliveInterval = new TimeSpan(0, 0, 0, 10),
                    Proxy = ...
                }
            };
using (var communicator = new BitfinexWebsocketCommunicator(url, wsClientFactory))
{
    ...
}

I also used an idea from your closed PR (about lowering timeout for that built-in reconnect policy). Check if it works, please.

dendle commented 6 years ago

Hi mate,

No problem - will deploy it tonight and see what happens.

Out of curiosity, were you getting the websocket connection getting closed due to inactivity, too?

Cheers, Matt

dendle commented 6 years ago

Hello Marfusios,

The fix certainly helped avoid the error caused by re-using the disposed websocket, but I still get disconnected, as below:

INF XRPUSD - last price: 1.3475 INF XRPUSD - STDEV 0.00266565286861575 INF BTCUSD - last price: 11367 INF BTCUSD - STDEV 27.6592381381964 INF XRPUSD - last price: 1.347 INF XRPUSD - STDEV 0.00266654664123795 INF BTCUSD - last price: 11355 INF BTCUSD - STDEV 27.650912481618 INF [BFX WEBSOCKET COMMUNICATOR] Last message received 1.27731436333333 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received 2.27731651 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received 3.277320265 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received more than 3 min ago. Hard restart.. INF [BFX WEBSOCKET COMMUNICATOR] Reconnecting... INF [BFX WEBSOCKET COMMUNICATOR] Last message received 1.82136661 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received 2.82137791666667 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received 3.82134397166667 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received more than 3 min ago. Hard restart.. INF [BFX WEBSOCKET COMMUNICATOR] Reconnecting... INF [BFX WEBSOCKET COMMUNICATOR] Last message received 1.82126731666667 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received 2.82121636166667 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received 3.82120505333333 min ago INF [BFX WEBSOCKET COMMUNICATOR] Last message received more than 3 min ago. Hard restart.. INF [BFX WEBSOCKET COMMUNICATOR] Reconnecting...

dendle commented 6 years ago

Think I have a plan on how to fix, will test and raise a PR if it works....