How to increase HttpClient timeout in Rhino.Compute C# client?

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 wrapper GhComputeClient that calls

    var 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.EvaluateDefinition with 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

Have you had a chance to look at the AppServer repo? This was a prototype project that a few McNeel developers created a few years ago… but essentially this is a Node.js server that acts as a middle-ware between the Rhino.Compute server and your HTML front-end. There are examples that you can look at which create HTML sliders and send the necessary data over to Rhino.Compute to be computed. I don’t know if this will specifically help your Timeout issue, but I believe you should then be able to set the Timeout of the Node.js server directly and have full control of the workflow.