swagger-api / swagger-api/swagger-codegen
C# Client for Net Core generate port exaustion
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I moved from Net Framework 4.7 to Net Core 3.1 and 5 and I have a critical issue.
The chsarp-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.
Swagger-codegen version
swagger-codegen-cli-2.4.8.jar with csharp client.
Suggest a fix/enhancement
Create a new client that support HttpClient for the net core part as OpenApi made.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the C# netcore client generation path in swagger-codegen-cli-2.4.8 and the RestSharp usage described in the issue. Reproduce repeated calls under .NET Core while observing sockets, then compare the behavior with .NET Framework. Done means the generated client reuses connections instead of opening a new socket for each call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100