Reporting Rest Service stops console app from exiting

1 Answer 223 Views
.NET 5 General Discussions Rest Service
Tursunkhuja
Top achievements
Rank 2
Iron
Iron
Veteran
Tursunkhuja asked on 24 Aug 2021, 06:20 AM

Hi,

We are using Telerik Reporting Rest service project in our server-side and as a report viewer we use HTML5 report viewer.  There is server project (console app) which run the Telerik Reporting service. We defined CancelKeyPress (Ctrl+C) to close the console app. If we press Ctrl+C it will close successfully. Before closing if we make a request to http://localhost:5000/api/reports/formats using postman or browser then it will  NOT close (See picture Server app after request.PNG). So, it says "Application is shutting down..." and it stays opened.

How to fix this issue?

You can use the attached demo project (ReportingServiceDemo.zip) to reproduce this issue. Startup project should be ServerConsole project which use CSharp.Net5.ReportingRestServiceCorsDemo project.

Thank you.

Neli
Telerik team
commented on 31 Aug 2021, 03:08 PM

Hi Tursunkhuja,

Thank you for the provided application.

The issue is known to us. I confirm that when starting the .NET Core demo from the command prompt when using the "Ctrl+C" combination the application seemingly stops, but one of the processes remains alive.
Honestly, we have never considered the possibility of such behavior. We have previously found out that this may be due to the framework not being able to stop the child processes - check the comment "muratg commented on Aug 8, 2017" in Ctrl+C doesn't kill the dotnet.exe process when running an ASP.NET Core app interactively in docker #960 thread. Note that our REST Service is actually a child process.

We tested in PowerShell and were able to stop all processes with "Ctrl+C" also of our .NET Core demo.

 

Tursunkhuja
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 08 Sep 2021, 04:05 AM | edited

Hi Neli,

We also tested in PowerShell and were not able to stop all processes with "Ctrl+C". Can you share the steps you tested in PowerShell? Also, did you run request that to get all report formats?

FYI: What is the best practice to stop the service?

 

Thank you!

Todor
Telerik team
commented on 10 Sep 2021, 11:31 AM

Hello Tursunkhuja,

Here is a link to a muted video demonstrating how the process may be stopped with "Ctrl+C". Note that when you open a viewer that makes requests to the server, the first "Ctrl+C" stops only one of the processes and the viewer stops working. The REST service also stops as there was no response to 'api/reports/formats' (not recorded in the video). The second "Ctrl+C" stops the entire application though. However, when the viewer wasn't activated, the application was stopped with a single break.

Regarding the best practices to stop service in Windows, please, check the post How to start and stop services manually on Windows 10.

Tursunkhuja
Top achievements
Rank 2
Iron
Iron
Veteran
commented on 17 Sep 2021, 04:37 AM | edited

Hello Todor,

The video demonstrating how we can stop the Html5IntegrationDemo process. Can you reproduce this with attached demo project which using ReportingRestServiceCorsDemo demo project?

Also asked the best way to stop Telerik Reporting service in the attached demo project.

 

Todor
Telerik team
commented on 21 Sep 2021, 12:40 PM

Hi Tursunkhuja,

Here is also a link to a silent video showing how the ReportingRestServiceCorsDemo demo project process gets stopped with double "Cltr+C".

When it comes to the best practices to stop the REST service, I'm afraid we don't have recommendations. You may check the post How to start and stop services manually on Windows 10.

If you have concerns about the leftovers when the service stops, have in mind that the service is stateless and it relies on its Storage to preserve the states of its clients. Generally, our code takes care of cleaning the expired clients on each request. This is controlled by the ClientSessionTimeout property. If you need to handle the storage release, you may do it with custom code, for example, in a proper event handler.

Aaron
Top achievements
Rank 1
Iron
commented on 10 Jan 2025, 09:02 PM | edited

Have there been any findings regarding what specifically within Telerik is preventing correct application shutdown in response to a sigterm? Are there any workarounds for this issue yet? I would like to point out that this is still an issue in net8.

1 Answer, 1 is accepted

Sort by
0
Accepted
Aaron
Top achievements
Rank 1
Iron
answered on 10 Jan 2025, 11:26 PM | edited on 10 Jan 2025, 11:28 PM

Workaround

At the end of main, instead of 

return 0;

I find that using the following heavy handed approach bypasses the problem. It probably introduces other issues, but I can't say I care in this context. It would be nice if Telerik had a way to shut their in-process services down gracefully during application teardown.

Environment.Exit(Environment.ExitCode);
return Environment.ExitCode; // Just in case your compiler can't deal and the return type is non-void

Tags
.NET 5 General Discussions Rest Service
Asked by
Tursunkhuja
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Aaron
Top achievements
Rank 1
Iron
Share this question
or