Hi everyone,
i am building a custom web application that uses Rhino.Compute (C#) as backend to run Grasshopper definitions.
The setup looks like this:
-
Frontend: HTML + JavaScript (
app.js), user interface with sliders, toggles etc. -
Middleware: ASP.NET Core (
Program.cs), with a wrapperGhComputeClientthat callsvar result = GrasshopperCompute.EvaluateDefinition(ghPath, trees); -
Backend: Rhino.Compute server (running locally)
The problem
I often get timeout errors when the Grasshopper definition takes longer than 100 seconds:
System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
I have already tried setting the environment variable RHINO_COMPUTE_TIMEOUT, but this only affects the server side. The error clearly comes from the client-side HttpClient.
In the source code of RhinoCompute.cs (8.x branch on GitHub), the GrasshopperCompute.EvaluateDefinition method internally uses System.Net.Http.HttpClient.
However, this HttpClient instance is not exposed in my version of the library, so we cannot configure its Timeout property.
My question
-
How can i increase the timeout of the client-side HttpClient used by
GrasshopperCompute.EvaluateDefinition? -
Is there a way to configure it in the current Rhino.Compute package (NuGet)?
-
Or do we need to replace
GrasshopperCompute.EvaluateDefinitionwith our own HttpClient implementation to get control over the timeout?
Example
What we would like to achieve (but can’t, because HttpClient isn’t exposed in our build):
ComputeServer.WebAddress = "http://localhost:5000";
ComputeServer.ApiKey = "my-key";
ComputeServer.HttpClient.Timeout = TimeSpan.FromMinutes(10);
Any advice on how to properly raise the client timeout in Rhino.Compute would be greatly appreciated
Best regards
Tim