JKorf / CryptoExchange.Net

A C# .netstandard base library used for implementing cryptocurrency exchange API's.
https://jkorf.github.io/CryptoExchange.Net/
MIT License
455 stars 203 forks source link

Exception "Value cannot be null" in RestApiClient.ParseRateLimitResponse #181

Closed EricGarnier closed 1 year ago

EricGarnier commented 1 year ago

Hi Jkorf, Thanks for all your work. I noticed a little exception with KuCoin in the RestApiClient.ParseRateLimitResponse method. I suspect that the responseHearder is null in case of error returned.

Here the trace.

Eric.

INFO: 2023/09/10 19:40:19:986 | Information | [8071] Creating request for https://api.kucoin.com/api/v1/orders INFO: 2023/09/10 19:40:20:005 | Warning | [8070] Error received in 20ms: {"code":"429000","msg":"too many request"} INFO: 2023/09/10 19:40:20:007 | Error | error System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.Any[TSource](IEnumerable1 source) at CryptoExchange.Net.RestApiClient.ParseRateLimitResponse(Int32 httpStatusCode, IEnumerable1 responseHeaders, String data) at CryptoExchange.Net.RestApiClient.GetResponseAsync[T](IRequest request, JsonSerializer deserializer, CancellationToken cancellationToken, Boolean expectedEmptyResponse) at CryptoExchange.Net.RestApiClient.SendRequestAsync[T](Uri uri, HttpMethod method, CancellationToken cancellationToken, Dictionary2 parameters, Boolean signed, Nullable1 parameterPosition, Nullable1 arraySerialization, Int32 requestWeight, JsonSerializer deserializer, Dictionary2 additionalHeaders, Boolean ignoreRatelimit) at Kucoin.Net.Clients.SpotApi.KucoinRestClientSpotApi.Execute[T](Uri uri, HttpMethod method, CancellationToken ct, Dictionary2 parameters, Boolean signed, Int32 weight, Boolean ignoreRatelimit, Nullable1 parameterPosition) at Kucoin.Net.Clients.SpotApi.KucoinRestClientSpotApiTrading.CancelOrderAsync(String orderId, CancellationToken ct)

JKorf commented 1 year ago

Thanks Eric, should be fixed in the latest version of CryptoExchange.Net. You can manually update to this version if this bug is an issue for you