JKorf / Bitfinex.Net

A C# .netstandard client library for the Bitfinex REST and Websocket API focusing on clear usage and models
https://jkorf.github.io/Bitfinex.Net/
MIT License
88 stars 49 forks source link

KeyNotFoundException - The given key 'cs' was not present in the dictionary. #139

Closed arkada38 closed 2 years ago

arkada38 commented 2 years ago

Describe the bug I'm using Bitfinex.Net 5.0.0-alpha1. I see a lot of KeyNotFound Exceptions. The given key 'cs' was not present in the dictionary. cs - WebSocket Checksum for Books and Row Books I'm using SubscribeToRawOrderBookUpdatesAsync with limit 1. It works as expected. But sometimes I see exceptions after trying to update existing orders.

To Reproduce I can't reproduce it. In the new clean project, all works as expected.

  1. 2 clients
  2. A few SubscribeToRawOrderBookUpdatesAsync on different symbols
  3. One order with periodic price updates

Expected behavior No exceptions.

Debug logging

dec 21 12:04:04 ser dotnet[21388]: 2021.12.21 12:04:04:232 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:04 ser dotnet[21388]: 2021.12.21 12:04:04:550 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:04 ser dotnet[21388]: 2021.12.21 12:04:04:620 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:04 ser dotnet[21388]: 2021.12.21 12:04:04:938 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:05 ser dotnet[21388]: 2021.12.21 12:04:05:008 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:05 ser dotnet[21388]: 2021.12.21 12:04:05:322 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:05 ser dotnet[21388]: 2021.12.21 12:04:05:390 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:05 ser dotnet[21388]: 2021.12.21 12:04:05:393 | Error | Bitfinex   | Socket 2 unhandled exception during message processing: KeyNotFoundException - The given key 'cs' was not present in the dictionary.
                                         at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
                                         at Bitfinex.Net.Clients.BitfinexSocketClient.HandleQueryResponse[T](SocketConnection s, Object request, JToken data, CallResult`1& callResult)
                                         at CryptoExchange.Net.BaseSocketClient.<>c__DisplayClass40_0`1.<QueryAndWaitAsync>b__0(JToken data)
                                         at CryptoExchange.Net.Sockets.PendingRequest.CheckData(JToken data)
                                         at CryptoExchange.Net.Sockets.SocketConnection.ProcessMessage(String data)
                                         at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.Handle[T](List`1 handlers, T data)
                                         at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.HandleMessage(Byte[] data, Int32 offset, Int32 count, WebSocketMessageType messageType)
dec 21 12:04:05 ser dotnet[21388]: 2021.12.21 12:04:05:703 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:05 ser dotnet[21388]: 2021.12.21 12:04:05:767 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:05 ser dotnet[21388]: 2021.12.21 12:04:05:796 | Error | Bitfinex   | Socket 2 unhandled exception during message processing: KeyNotFoundException - The given key 'cs' was not present in the dictionary.
                                         at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
                                         at Bitfinex.Net.Clients.BitfinexSocketClient.HandleQueryResponse[T](SocketConnection s, Object request, JToken data, CallResult`1& callResult)
                                         at CryptoExchange.Net.BaseSocketClient.<>c__DisplayClass40_0`1.<QueryAndWaitAsync>b__0(JToken data)
                                         at CryptoExchange.Net.Sockets.PendingRequest.CheckData(JToken data)
                                         at CryptoExchange.Net.Sockets.SocketConnection.ProcessMessage(String data)
                                         at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.Handle[T](List`1 handlers, T data)
                                         at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.HandleMessage(Byte[] data, Int32 offset, Int32 count, WebSocketMessageType messageType)
dec 21 12:04:07 ser dotnet[21388]: 2021.12.21 12:04:07:594 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:07 ser dotnet[21388]: 2021.12.21 12:04:07:658 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:10 ser dotnet[21388]: 2021.12.21 12:04:10:995 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:11 ser dotnet[21388]: 2021.12.21 12:04:11:058 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:11 ser dotnet[21388]: 2021.12.21 12:04:11:631 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:11 ser dotnet[21388]: 2021.12.21 12:04:11:699 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:11 ser dotnet[21388]: 2021.12.21 12:04:11:749 | Error | Bitfinex   | Socket 2 unhandled exception during message processing: KeyNotFoundException - The given key 'cs' was not present in the dictionary.
                                         at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
                                         at Bitfinex.Net.Clients.BitfinexSocketClient.HandleQueryResponse[T](SocketConnection s, Object request, JToken data, CallResult`1& callResult)
                                         at CryptoExchange.Net.BaseSocketClient.<>c__DisplayClass40_0`1.<QueryAndWaitAsync>b__0(JToken data)
                                         at CryptoExchange.Net.Sockets.PendingRequest.CheckData(JToken data)
                                         at CryptoExchange.Net.Sockets.SocketConnection.ProcessMessage(String data)
                                         at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.Handle[T](List`1 handlers, T data)
                                         at CryptoExchange.Net.Sockets.CryptoExchangeWebSocketClient.HandleMessage(Byte[] data, Int32 offset, Int32 count, WebSocketMessageType messageType)
dec 21 12:04:14 ser dotnet[21388]: 2021.12.21 12:04:14:537 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:14 ser dotnet[21388]: 2021.12.21 12:04:14:598 | Information | Bitfinex   | Going to update order 81931594508
dec 21 12:04:20 ser dotnet[21388]: 2021.12.21 12:04:20:454 | Information | Bitfinex   | Going to update order 81931594507
dec 21 12:04:20 ser dotnet[21388]: 2021.12.21 12:04:20:519 | Information | Bitfinex   | Going to update order 81931594508
JKorf commented 2 years ago

Hi, thanks for the report. This should be fixed in alpha2. Let me know if you have any more issues.

arkada38 commented 2 years ago

Fixed in alpha2 🙏