glitch100 / BinanceDotNet

Official C# Wrapper for the Binance exchange API, with REST and WebSocket endpoints
https://www.nuget.org/packages/BinanceDotNet/
MIT License
161 stars 138 forks source link

DisposableBinanceWebSocketClient exception #166

Open senzacionale opened 5 years ago

senzacionale commented 5 years ago

I am getting this error

04/12/2019 12:51:13|Error|WebSocket.messagec|Newtonsoft.Json.JsonSerializationException: A member with the name 'e' already exists on 'BinanceExchange.API.Models.WebSocket.BinanceKlineData'. Use the JsonPropertyAttribute to specify another name.
                             at Newtonsoft.Json.Serialization.JsonPropertyCollection.AddProperty(JsonProperty property)
                             at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties(Type type, MemberSerialization memberSerialization)
                             at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
                             at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
                             at Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver.ResolveContract(Type type)
                             at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContract(Type type)
                             at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe(Type type)
                             at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
                             at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
                             at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
                             at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
                             at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
                             at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
                             at BinanceExchange.API.Websockets.AbstractBinanceWebSocketClient.<>c__DisplayClass26_0`1.<CreateBinanceWebSocket>b__1(Object sender, MessageEventArgs e)
                             at WebSocketSharp.Ext.Emit[TEventArgs](EventHandler`1 eventHandler, Object sender, TEventArgs e)
                             at WebSocketSharp.WebSocket.messagec(MessageEventArgs e)

Code:

using (var binanceWebSocketClient  = new DisposableBinanceWebSocketClient(client)) 
                {                
                    foreach (var ticker in tickers)
                    {
                        var socketId = binanceWebSocketClient.ConnectToKlineWebSocket(ticker, BinanceExchange.API.Enums.KlineInterval.FourHours, KlineHandler);
                        _log.Info($"Registered to {ticker} with socket id {socketId}");
                    }
                }