devhl
Slow HttpClient responses
I have a program which polls an API. It usually works great, but lately, I've been seeing many HttpClient requests take up to 30 seconds despite my timeouts. Here is how I configured the client. And here is the library where these methods to configure Polly reside https://github.com/devhl-labs/CocApi/blob/47f7e1ec097fdfd7f50e60436d7a0fe96d87f721/src/CocApi.Test/Program.cs#L62
And here is the request itself. After the request, I log the difference between the current DateTime and the requestedAtLocalVar, which is showing me up to 30 seconds. It normally shows less than a second.
31 replies
❔ Can't share JsonSerializerOptions with several SerializerContext
From this SO I see that you can't share options with multiple contexts. This is what I am observing. To work around this limitation, when I construct my context with a copy of the options. This seems like the wrong thing to do, so I am looking for input from the community. The reason I am using multiple contexts is when I tried with only one context, there was a warning about a name conflict. Since what I am talking about here is generated C#, it seemed wise to avoid the warning and just use multiple contexts.
Here is the test showing the de/serialization works as I have it.
https://github.com/devhl-labs/openapi-generator/blob/f237e51991d5c1c7ef5500bba8ff51ea319f0353/samples/client/petstore/csharp/OpenAPIClient-generichost-manual-tests/OpenAPIClient-generichost-manual-tests/UnitTest1.cs#L49
Here is the context I am using in the above test.
https://github.com/devhl-labs/openapi-generator/blob/f237e51991d5c1c7ef5500bba8ff51ea319f0353/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/Category.cs#L184C18-L184C18
Here is how the host is getting the options and the context.
https://github.com/devhl-labs/openapi-generator/blob/f237e51991d5c1c7ef5500bba8ff51ea319f0353/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Client/HostConfiguration.cs#L137
Is my approach wrong?
2 replies
❔ Utf8JsonReader.GetString exceptions
This document seems to contradict itself. The returns section says if the token is null then you get null, but the exceptions say null will cause an exception. Am I understanding this right and it is wrong documentation?
https://learn.microsoft.com/en-us/dotnet/api/system.text.json.utf8jsonreader.getstring?view=net-7.0#returns
9 replies