Open Closed

Error on GetHealthReport in Production #7057


User avatar
0
lan.dang created
  • ABP Framework version: v8.0.1
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server, Oracle, MySQL, PostgreSQL, etc..)
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I got this error in Host app 2024-04-18 02:15:02.991 +00:00 [ERR] GetHealthReport threw an exception when trying to get report from http://a7fe589a2946/health-status configured with name DruidAI Health Status. System.Net.Http.HttpRequestException: Connection refused (a7fe589a2946:80) ---> System.Net.Sockets.SocketException (111): Connection refused at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem) at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.

This is my HealthCheck configure public static class HealthChecksBuilderExtensions { public static void AddDruidAIHealthChecks(this IServiceCollection services) { // Add your health checks here var healthChecksBuilder = services.AddHealthChecks(); healthChecksBuilder.AddCheck

    services.ConfigureHealthCheckEndpoint("/health-status");
    
    // If you don't want to add HealthChecksUI, remove following configurations.
    var healthChecksUiBuilder = services.AddHealthChecksUI(settings =>
    {
        settings.AddHealthCheckEndpoint("DruidAI Health Status", $"http://{Dns.GetHostName()}/health-status");
    });
    
    // Set your HealthCheck UI Storage here
    healthChecksUiBuilder.AddInMemoryStorage();
    
    services.MapHealthChecksUiEndpoints(options =>
    {
        options.UIPath = "/health-ui";
        options.ApiPath = "/health-api";
    });
}

private static IServiceCollection ConfigureHealthCheckEndpoint(this IServiceCollection services, string path)
{
    services.Configure<AbpEndpointRouterOptions>(options =>
    {
        options.EndpointConfigureActions.Add(endpointContext =>
        {
            endpointContext.Endpoints.MapHealthChecks(
                new PathString(path.EnsureStartsWith('/')),
                new HealthCheckOptions
                {
                    Predicate = _ => true,
                    ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse,
                    AllowCachingResponses = false,
                });
        });
    });

    return services;
}

private static IServiceCollection MapHealthChecksUiEndpoints(this IServiceCollection services, Action<global::HealthChecks.UI.Configuration.Options> setupOption = null)
{
    services.Configure<AbpEndpointRouterOptions>(routerOptions =>
    {
        routerOptions.EndpointConfigureActions.Add(endpointContext =>
        {
            endpointContext.Endpoints.MapHealthChecksUI(setupOption);
        });
    });

    return services;
}

}

It seems error on Dns.GetHostName() as I return "a7fe589a2946", right? can i get host name from Configuration app setting?


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://support.abp.io/QA/Questions/3448/How-to-Deploy-Net-60-web-api-Application-on-windows-server-IIS#answer-5f70c8df-651b-08ba-ec76-3a053289a6f4

    https://support.abp.io/QA/Questions/3327/Health-Check-Problem-on-IIS-SystemUriFormatException-Invalid-URI-The-hostname-could-not-be-parsed#answer-51baf847-087a-2aa1-1d76-3a04d9420894

  • User Avatar
    0
    lan.dang created

    Thank you, I solved the error : this method in azure app service does not work well {Dns.GetHostName()}

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Good news.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on July 17, 2025, 06:22