Kevin-Bronsdijk / kraken-net

Official Kraken.io .Net client
https://kraken.io
GNU General Public License v2.0
19 stars 5 forks source link

Timeout during upload due to default HttpClient.Timeout property #26

Open Shane32 opened 3 years ago

Shane32 commented 3 years ago

HttpClient.Timeout defaults to a 100 second timeout. I have a reproducible problem where this timeout period is not long enough for Kraken to finish processing the request. It could be due to throttling; I am not sure. However, if I use reflection to set the timeout of the private HttpClient _client field on the Connection object to System.Threading.Timeout.InfiniteTimeSpan, then the request completes successfully.

This is a reproducible problem given the same inputs. I suggest that you set the Timeout property to infinite by default, or add an argument for a custom timeout value on the Connection.Create static method. Keep in mind that since there are already overloads of the conversion methods that accept a CancellationToken, a custom timeout can be implemented, as described by MS's documentation:

See https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=net-5.0 :

The same timeout will apply for all requests using this HttpClient instance. You may also set different timeouts for individual requests using a CancellationTokenSource on a task. Note that only the shorter of the two timeouts will apply.