JKorf / Bittrex.Net

A C# .Net wrapper for the Bittrex web API including all features easily accessible and usable
MIT License
141 stars 62 forks source link

Receiving heartbeat logs internal error message. #209

Closed daerhiel closed 2 years ago

daerhiel commented 2 years ago

Describe the bug When subscribing to Bittrex Heartbeats the error is logged internally every time the message is received from server.

To Reproduce Subscribe to the heartbeat with the following call:

        var client = serviceProvider.GetRequiredService<IBittrexSocketClient>();
        _heartbeat = await client.SpotStreams.SubscribeToHeartbeatAsync(OnHeartbeat).ToException(Descriptor);

Expected behavior I guess there's a problem with deserializing the timestamp from heartbeat message.

Debug logging

2022/02/22 22:02:20:048 | Error | Bittrex    | Socket 1 Exception during message processing
Exception: InvalidCastException - Invalid cast from 'System.DateTime' to 'Bittrex.Net.Objects.Models.Socket.BittrexTickersUpdate'.
   at System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
   at System.DateTime.System.IConvertible.ToType(Type type, IFormatProvider provider)
   at Bittrex.Net.Clients.BittrexSocketClient.<>c__DisplayClass8_0`1.<SubscribeInternalAsync>b__0(DataEvent`1 data)
   at CryptoExchange.Net.BaseSocketClient.<>c__DisplayClass49_0`1.<AddSubscription>g__InternalHandler|0(MessageEvent messageEvent)
   at CryptoExchange.Net.Sockets.SocketConnection.HandleData(MessageEvent messageEvent)

Data: {
  "H": "C3",
  "M": "heartbeat",
  "A": []
}
2022/02/22 22:02:20:050 | Warning | Bittrex    | Socket 1 Message not handled: {
  "H": "C3",
  "M": "heartbeat",
  "A": []
}
JKorf commented 2 years ago

Hi, this was an issue when using the HeartBeat subscription in combination with other subscriptions. It has been fixed in the latest version

daerhiel commented 2 years ago

Hi, it works good now, thank you :)