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

Set specific HttpClient to use #1385

Closed
Steffx115 opened this issue Jun 17, 2024 · 3 comments
Closed

Set specific HttpClient to use #1385

Steffx115 opened this issue Jun 17, 2024 · 3 comments

Comments

@Steffx115
Copy link

I am currently trying to read bulk data from BinanceApi into a DB, but cant modify the default httpclient as i assume it would interfere with other libraries using the default client.

Is it possible to set a specific httpclient(factory) to use?

@JKorf
Copy link
Owner

JKorf commented Jun 17, 2024

If you're using DI to register the Binance clients (services.AddBinance(..);) then the http client will be internally registered as a typed client like this

services.AddHttpClient<IBinanceRestClient, BinanceRestClient>(options =>
{
    options.Timeout = restOptions.RequestTimeout;
})

If you're not using DI you can pass an http client in the BinanceRestClient constructor:

var client = new BinanceRestClient(httpClientInstance, loggerFactory, options =>{});

@Steffx115
Copy link
Author

Is a different HttpClient used for each request if none is set?

@JKorf
Copy link
Owner

JKorf commented Jun 22, 2024

A single HttpClient is used per client. So if you're re-using the same client the same HttpClient is used, but if you're constructing clients each time then a new HttpClient is used each time

@JKorf JKorf closed this as completed Jul 16, 2024
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