Hi,
I have encountered a timeout issue when calling a service using JsonServiceClient from an Azure Function (a .Net Core project). AFAIK the issue is not related to the Azure environment since I was able to reproduce the issue outside of an Azure Function by creating a .Net Core test.
It looks like the Timeout
property of the client is ignored and the request times out after the default value of 100 seconds. As a workaround I am using the sync Send and it is working as expected.
For testing purposes I tried using the full .Net Framework (4.8) and the issue does not occurs. It only happens in .Net Core.
You will find below some code to reproduce the issue.
// service
public class MyServices : Service
{
public async Task<HelloResponse> Any(Hello request)
{
await Task.Delay(TimeSpan.FromMinutes(3)).ConfigureAwait(false);
return new HelloResponse { Result = $"Hello, {request.Name}!" };
}
}
// Unit tests, must be called from a .Net Core project
[TestMethod]
public async Task TestMethodAsync()
{
var baseUrl = "http://localhost:14993";
var client = new JsonServiceClient(baseUrl);
client.Timeout = TimeSpan.FromMinutes(5);
var request = new Hello { Name = "Bob" };
var response = await client.SendAsync(request).ConfigureAwait(false);
}
[TestMethod]
public void TestMethodSync()
{
var baseUrl = "http://localhost:14993";
var client = new JsonServiceClient(baseUrl);
client.Timeout = TimeSpan.FromMinutes(5);
var request = new Hello { Name = "Bob" };
var response = client.Send(request);
}