Refit with HttpClientFactory creates many connections #1531
Replies: 1 comment
-
This is not an issue as I had HttpResponseMessage returning from the refit method and I wasn't disposing it. Changing the return type to string or any other type resolved the issue. [Get("")] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have a straightforward demo Web API using Refit where I am using the following code to register ISomeApi refit contract:
My controller is injected with an ISomeApi instance that I use inside a controller action.
The problem is every time, I hit that controller action, I see a new connection established (using netstat -ano -b | findstr ), I see over 50 connections after hitting the endpoint about 50+ times.
My expectation using HttpClientFactory was that it reuses connections so I registered a named Client and injected IHttpClientFactory in the code:
When I used the injected httpClientFactory to create and use an HttpClient, no matter how many times I hit that endpoint, I only see one connection.
Can somebody explain if I am doing something wrong, or is it a bug?
Thank You,
Rizwan
Beta Was this translation helpful? Give feedback.
All reactions