Search code examples
c#asp.net-coremicroservices

.net core microservices deployed on Windows 2012 R2 freezes after days working fine


I have two different microservices developed in C#. They listen in a Port for a GET call and returns a JSON. They have been developed by two different persons and run in two different servers (Windows 2012 R2)

They work well for days, but at a certain moment stop returning the JSON after making the call

If I access the server via RDP I can see that the microservice console is frozen, when it should be showing the log. If I press a key, the microservice works again for a while that could be days. But the problem appears again sooner or later (sometimes in minutes).

Restarting the microservice did not fix the problem.

I tried to use netstat to see if there were any problems like a lot of open sockets, but not.

The program starts this way in program.cs

public static IWebHostBuilder CreateWebHostBuilder(string[] args)
    {
        return WebHost.CreateDefaultBuilder(args)
             .UseConfiguration(new ConfigurationBuilder().Build())
             .UseKestrel((ctx, opt) =>
             {
                 opt.Listen(IPAddress.Parse("127.0.0.1"), 8098);
                 opt.Listen(IPAddress.Parse("5.35.249.161"), 8098);
             })
             .UseStartup<Startup>();
    }

And the action returns an

[HttpGet]
public IActionResult Get()

I consulted the sysadmin but he could not find anything out from normal.

We cannot understand why the microservices (programmed by two different persons in two different countries and no copy/paste one from another and running on different servers) behave that way.


Solution

  • Bruno Belmondo comment points me to the solution.

    The problem is that I or other programmers of the team clicked with the mouse in the console app and therefore the microservice frozen.

    The long term solution (as we have around 10 microservices and will have more in the future) is to use Chris Pratt solution and convert the microservices into windows services.