Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectToIndividualSymbolTickerWebSocket !ticker@arr endpoint #154

Open
Danford opened this issue Jun 19, 2019 · 1 comment
Open

ConnectToIndividualSymbolTickerWebSocket !ticker@arr endpoint #154

Danford opened this issue Jun 19, 2019 · 1 comment

Comments

@Danford
Copy link

Danford commented Jun 19, 2019

Issue Overview

/// <summary>
/// Connect to the All Market Symbol Ticker WebSocket
/// </summary>
/// <param name="messageEventHandler"></param>
/// <returns></returns>
public Guid ConnectToIndividualSymbolTickerWebSocket(BinanceWebSocketMessageHandler<BinanceAggregateTradeData> messageEventHandler)

Connecting to this endpoint produces an error with the message:

Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'BinanceExchange.API.Models.WebSocket.BinanceAggregateTradeData' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.

StackTrace:

at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(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 BinanceExchange.API.Websockets.AbstractBinanceWebSocketClient.<>c__DisplayClass22_0`1.<CreateBinanceWebSocket>b__1(Object sender, MessageEventArgs e) in C:\Users\joshu\Documents\Programming\Repo\BinanceDotNet\BinanceExchange.API\Websockets\AbstractBinanceWebSocketClient.cs:line 250
at WebSocketSharp.WebSocket.messagec(MessageEventArgs e)

line 250 AbstractBinanceWebSocketClient.cs
var data = JsonConvert.DeserializeObject<T>(e.Data);

where T = BinanceWebSocketMessageHandler<BinanceAggregateTradeData>

Package Version: 4.10

Repro Steps

            socket = new InstanceBinanceWebSocketClient(client);
            socket.ConnectToIndividualSymbolTickerWebSocket(a =>
            {
                System.Console.WriteLine($"{JsonConvert.SerializeObject(a, Formatting.Indented)}");
            });

Other Information

It would appear to me that the correct function declaration should be:
public Guid ConnectToIndividualSymbolTickerWebSocket(BinanceWebSocketMessageHandler\<List\<BinanceTradeData>> messageEventHandler)
but this causes other issues with the type constrant where T : IWebSocketResponse in AbstractBinanceWebSocketClient::CreateBinanceWebSocket.

I'm happy to assist with fixing this issue if you have any advice on an acceptable resolution.

@glitch100
Copy link
Owner

Could you provide the JSON payload that it tries to Deserialize? We can then work on a decent solution 👍 @Danford

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants