Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Manage lifetime of default HttpClientHandler. #17

Open
ddunkin opened this issue Jan 11, 2019 · 1 comment
Open

Manage lifetime of default HttpClientHandler. #17

ddunkin opened this issue Jan 11, 2019 · 1 comment

Comments

@ddunkin
Copy link
Member

ddunkin commented Jan 11, 2019

If WebServiceRequestSettings.GetHttpClient is not used, a new HttpClient and HttpClientHandler are created for every request. This has been observed to lead to sockets being left open indefinitely and eventual resource starvation on .NET Core on Linux.

The lifetime of the default HttpClientHandler should be managed some how, possibly as a shared static or scoped to the lifetime of the client.

Alternatively, always require WebServiceRequestSettings.GetHttpClient to be provided.

@ddunkin
Copy link
Member Author

ddunkin commented Jan 14, 2019

An issue with sharing the HttpClientHandler is that the WebServiceRequest.DisableAutoRedirect option is per-request, but it is implemented by setting HttpClientHandler.AllowAutoRedirect. The Libronix version of this option is used by Faithlife code in several places related to authentication and LibApi. Some options for handling this are:

  1. Implement redirect handling with a MessageProcessingHandler in the handler chain.
  2. Remove redirect support.
  3. Move DisableAutoRedirect from WebServiceRequest to WebServiceRequestSettings.

Moving DisableAutoRedirect would be the most straight-forward change for this library. The consumers should be able to accommodate the change without trouble.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant