-
Notifications
You must be signed in to change notification settings - Fork 345
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
HttpMessageHandler Passed To Constructor Of FhirClient Gets Disposed When FhirClient Is Disposed #2029
Comments
May also be related to #2036 |
Have confirmed this behaviour, and have a simple fix for it. |
…can be disposed when it is done with it.
Along with this common module version |
Good idea to use the boolean We will create a PR for this. |
Thanks @brianpos, your fix solves the problem with the port exhaustion as the message handler can then be reused. As a side note: It would be even easier if the constructor of the class FhirClient would take an HttpClient or an IHttpClientFactory as a parameter instead of an HttpMessageHandler, as this would allow using the HttpClientFactory-Pattern (see https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-6.0) already mentioned in issue #2036. |
…sion that includes the default parameter for the disposeHandler (even though we pass it throuth)
…posed when it is done with it. # Conflicts: # src/Hl7.Fhir.Core.Tests/Rest/FhirClientTests.cs
…sion that includes the default parameter for the disposeHandler (even though we pass it throuth)
Describe the bug
We are using the firely-net-sdk in a project and are experiencing port exhaustion when the server-web-api using the sdk is under high load. To deal with the issue, I tried to reuse the HttpMessageHandler that gets passed into the constructor of the FhirClient. However, the HttpMessageHandler gets disposed with the HttpClientRequester, that is created in the FhirClient's constructor.
Expected behavior
If I am not mistaken, a class instance passed into a constructor should in general not be disposed by the class using it. The BaseFhirClient should therefore only dispose the HttpMessageHandler if the class BaseFhirClient or the FhirClient created it. If the HttpMessageHandler was passed as a constructor parameter, the handler should not be disposed with the BaseFhirClient.
Version used:
Kind regards,
Ashwani Mehlem
The text was updated successfully, but these errors were encountered: