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

HttpClient should be a static instance, and threadpool expired periodically #897

Closed
mikeball opened this issue Jun 25, 2019 · 1 comment · Fixed by #839
Closed

HttpClient should be a static instance, and threadpool expired periodically #897

mikeball opened this issue Jun 25, 2019 · 1 comment · Fixed by #839

Comments

@mikeball
Copy link

Currently HttpClient as used in https://github.com/sendgrid/sendgrid-csharp/blob/master/src/SendGrid/SendGridClient.cs#L32 creates multiple instances of HttpClient which is improper use of the class.

It which needlessly recreates/duplicates the underlying tcp connection pools for each instance of SendGridClient created. More troublesome, it leaves the underlying pools of tcp connections in a wait status for several minutes after each instance of SendGridClient is disposed, using up limited network ports which can often cause issues on cloud platforms such as azure which are easily exhausted.

HttpClient instances should be static, and the underlying threadpool connections should be expired periodically to account for DNS changes for the remote host.

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

@aevitas
Copy link
Contributor

aevitas commented Jun 25, 2019

See #839 @akunzai implemented this over half a year ago and it's awaiting response from one of the repository owners.

I agree this should be a priority change, the client currently doesn't play nice with a myriad of cloud technologies and paradigms and we should be making rapid steps towards improving the situation.

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

Successfully merging a pull request may close this issue.

2 participants