Tord Larsen
Tord Larsen

Reputation: 2838

Visual Studio with ASP-NET and Angular show TimeoutException in Browser

When staring debug after 60 sec waiting this shows in the browser. Refreshing the browser window and 15 sec later everything works ok

An unhandled exception occurred while processing the request. TimeoutException: The Angular CLI process did not start listening for requests within the timeout period of 50 seconds. Check the log output for error information.

Any idea?

Upvotes: 3

Views: 3226

Answers (3)

shriyansh jain
shriyansh jain

Reputation: 109

For development purpose if you are getting the error as 'TimeoutException: The Angular CLI process did not start listening for requests within the timeout period of 0 seconds.' .

Please follow these 2 steps which work for me as well :

  1. In command prompt, Run the 'ng serve' command to run the angular solution.
  2. In startup.cs file, change the start up timeout to minutes. even it will not take that much of time as angular solution is already running.

-> spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);

Please mark the answer if it helps you !!

Thanks.

Upvotes: 0

Tomas Krchnak
Tomas Krchnak

Reputation: 449

I was able to fix this issue by modifying package.json file. It was needed to slightly change "start" script ("start": "echo Starting... && ng serve"). Additional info here: https://jasontaylor.dev/asp-net-core-angular-9-upgrade/

Upvotes: 1

Tony
Tony

Reputation: 20092

That is because the angular CLI is not bootstrap fast enough so to fix it you have 2 options

Increase a time out in Startup.cs

app.UseSpa(spa =>
    {
        spa.Options.SourcePath = "ClientApp";

        if (env.IsDevelopment())
        {
            spa.Options.StartupTimeout = new TimeSpan(0, 0, 80); // 80 seconds
            spa.UseAngularCliServer(npmScript: "start");
        }
    });

or navigate to ClientApp folder run ng serve and wait for compilation process is done so you can run your project again

Update: I find the way to resolve this error is running dotnet run in the cmd

Upvotes: 3

Related Questions