Skip to content
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

How to set the DaprClient invoke timeout #1007

Closed
johnseed opened this issue Jan 9, 2023 · 8 comments
Closed

How to set the DaprClient invoke timeout #1007

johnseed opened this issue Jan 9, 2023 · 8 comments
Labels
good first issue Good for newcomers
Milestone

Comments

@johnseed
Copy link

johnseed commented Jan 9, 2023

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
@johnseed
Copy link
Author

johnseed commented Jan 9, 2023

Add some parameters here?

var httpClient = HttpClientFactory is object ? HttpClientFactory() : new HttpClient();

@halspang
Copy link
Contributor

halspang commented Feb 1, 2023

@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.

@ronnie-chew
Copy link

@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.

@MishaVernik
Copy link

I'm facing the same shit, wtf with .net 7

@huxingye
Copy link

huxingye commented Apr 7, 2023

In DaprClientBuilder.cs
`

internal DaprClientBuilder UseHttpClientFactory(Func<HttpClient> factory)
{
  this.HttpClientFactory = factory;
  return this;
}

`
Why not use public? We cannot customize the timeout time

@BartNetJS
Copy link

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 factory)

@fissssssh
Copy link

how about this? https://docs.dapr.io/operations/resiliency/resiliency-overview/

@yaron2 yaron2 added the good first issue Good for newcomers label Feb 27, 2024
@philliphoff philliphoff added this to the v1.14 milestone Jul 23, 2024
@philliphoff
Copy link
Collaborator

Closed with #1252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

9 participants