dotnet-sdk
dotnet-sdk copied to clipboard
How to set the DaprClient invoke timeout
How to set the DaprClient invoke timeout
I have an API that takes 2 minutes to complete, but the DaprClient invoke will time out after 100 seconds.
System.Threading.Tasks.TaskCanceledException: 'The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.'
at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts)
at System.Net.Http.HttpClient.<<SendAsync>g__Core|83_0>d.MoveNext()
at Dapr.Client.DaprClientGrpc.<InvokeMethodWithResponseAsync>d__24.MoveNext()
at Dapr.Client.DaprClientGrpc.<InvokeMethodAsync>d__26`1.MoveNext()
at Program.<<Main>$>d__0.MoveNext() in C:\Users\John\source\repos\DaprGround\Invoke.Client\Program.cs:line 17
Add some parameters here? https://github.com/dapr/dotnet-sdk/blob/ab5403ed015d7ba46099cf829186e2ea7d6264a5/src/Dapr.Client/DaprClientBuilder.cs#L166
@johnseed - Thanks for bringing this up. We do need a way to expose this, which would probably be best done by exposing the actual factory/creation method. I'll discuss it with some of the other active people in the repo.
In the meantime, since you're using a direct http invoke, you can also do this with a raw HttpClient. Then you'd have full control over it, but you'd need to construct the endpoint yourself.
@halspang any updates on this one? We have a requirement to let user download large attachments that could take more than 5 minutes to generate on server. But it's always timeout after 100 seconds.
I'm facing the same shit, wtf with .net 7
In DaprClientBuilder.cs `
internal DaprClientBuilder UseHttpClientFactory(Func<HttpClient> factory)
{
this.HttpClientFactory = factory;
return this;
}
` Why not use public? We cannot customize the timeout time
I'm looking also into this to use the HttpClientFactory to inject middleware like for example an exception logger middleware
for example: A factory functions like this
Func<HttpClient> factory = () =>
{
var httpClientHandler = new HttpClientHandler();
var loggingMiddleware = new LogInternalServerErrorMiddleware(httpClientHandler);
return new HttpClient(loggingMiddleware);
};
And pass it to UseHttpClientFactory(Func<HttpClient> factory)
how about this? https://docs.dapr.io/operations/resiliency/resiliency-overview/
Closed with #1252