[BUG][csharp-netcore] C# Client for Net Core generate port exaustion
See original GitHub issueDescription
I moved from Net Framework 4.7 to Net Core 3.1 and 5 and I have a critical issue.
The csharp-netcore client uses RestSharp and is not stable with Net Core actually. See this issue. It seems to be a net core breaking change they won’t patch in time and actually this is impacting on RestSharp.
It silently open at every call a new socket, creating a new HttpWebRequest each time. This is a behavior totally different in NetFramework where it keep the same. You can reproduce it easily generating a simple client and using it in both verisons. Test multiple calls and watch the connection in Wireshark, I can further add images or a report if you prefer.
While NetFramework honors the keep-alive header (supported also by the server) in Net Core it doesnt.
- In NetFramework it do the handshake and TLS connection just 1 time, and it consumes just one socket keeping working on it with the next calls.
- In Net Core not, it open a new socket each times.
This is critical because you cannot understand it when moving your client to net core until you have a feedback from the server closing the connections to all.
I see there is a version with HttpClient, i tried it but it create every time:
var handler = new HttpClientHandler(); var client = new HttpClient();
openapi-generator version
openapi-generator-cli-5.1.0.jar with csharp-netcore client without settings.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Pull request is up which fixes this issue
You are absolutely right. The issue is that HttpClient is not disposed. Will fix immediately. There is also the additional property reUseHttpClient which should alleviate the problem as only a single HttpClient is used for the whole ApiClient then.
Passing in an HttpClient is on the roadmap.