Open Closed

Health Check Problem on IIS (System.UriFormatException: Invalid URI: The hostname could not be parsed.) #3327


User avatar
0
piseth created

I have a domain name, and the following is my binding info. Please note that I have to configure binding like that, so i want to fix the following log:

2022-06-26 18:58:58.423 +03:00 [INF] Executing endpoint 'Health checks' 2022-06-26 18:58:58.428 +03:00 [INF] Executed endpoint 'Health checks' 2022-06-26 18:58:58.428 +03:00 [INF] Request finished HTTP/0.9 GET https:///health-check - - - 200 - - 8.5607ms 2022-06-26 18:59:00.180 +03:00 [INF] Request starting HTTP/0.9 GET https:///health-check - - 2022-06-26 18:59:00.184 +03:00 [WRN] Invalid URI: The hostname could not be parsed. System.UriFormatException: Invalid URI: The hostname could not be parsed. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions) at System.Uri..ctor(String uriString) at System.UriBuilder.get_Uri() at Volo.Abp.AspNetCore.Auditing.AspNetCoreAuditLogContributor.BuildUrl(HttpContext httpContext) at Volo.Abp.AspNetCore.Auditing.AspNetCoreAuditLogContributor.PreContribute(AuditLogContributionContext context) at Volo.Abp.Auditing.AuditingHelper.ExecutePreContributors(AuditLogInfo auditLogInfo)


9 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    • Steps to reproduce the issue:"
  • User Avatar
    0
    piseth created

    Hi,

    I just publish my application on IIS and start it. When i check in the log file, i can see those error.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I could not reproduce the problem. can you please provide the steps? thanks.

  • User Avatar
    0
    piseth created

    Hi,

    I could not reproduce the problem. can you please provide the steps? thanks.

    In Bindings, i want you don't provide IP address and make it "*" inside IP address? For me on port 443, i don't provide IP address. Plz see the below image

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can check the discussion here: https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/700#issuecomment-745881226

    You can try:

    var healthChecksUiBuilder = services.AddHealthChecksUI(settings =>
    {
        settings.AddHealthCheckEndpoint("MyProjectName Health Status", "https://yourwebsite.com/health-status");
    });
    
    services.MapHealthChecksUiEndpoints(options =>
    {
        options.UIPath = "https://yourwebsite.com/health-ui";
        options.ApiPath = "https://yourwebsite.com/health-api";
    });
    
  • User Avatar
    0
    piseth created

    Hi,

    You can check the discussion here: https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/700#issuecomment-745881226

    You can try:

    var healthChecksUiBuilder = services.AddHealthChecksUI(settings => 
    { 
        settings.AddHealthCheckEndpoint("MyProjectName Health Status", "https://yourwebsite.com/health-status"); 
    }); 
     
    services.MapHealthChecksUiEndpoints(options => 
    { 
        options.UIPath = "https://yourwebsite.com/health-ui"; 
        options.ApiPath = "https://yourwebsite.com/health-api"; 
    }); 
    

    Hi,

    Sorry for my late reply. Thanks for your info.

    If i input full url like the following. I will get an error

    var healthChecksUiBuilder = services.AddHealthChecksUI(settings => { settings.AddHealthCheckEndpoint("MyProjectName Health Status", "https://yourwebsite.com/health-status"); });

    services.MapHealthChecksUiEndpoints(options => { options.UIPath = "https://yourwebsite.com/health-ui"; options.ApiPath = "https://yourwebsite.com/health-api"; });

    Here is error:

    Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module MyProject.Web.MyProjectWebModule, MyProject.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: The value for customized path can't be null and need to start with / character. (Parameter 'ApiPath'). See the inner exception for details. ---> System.ArgumentException: The value for customized path can't be null and need to start with / character. (Parameter 'ApiPath') at Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.<>c.<EnsureValidApiOptions>b__1_0(String path, String argument) at Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.EnsureValidApiOptions(Options options) at Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapHealthChecksUI(IEndpointRouteBuilder builder, Action1 setupOptions) at MyProject.Web.HealthChecks.HealthChecksBuilderExtensions.<>c__DisplayClass4_0.<MapHealthChecksUiEndpoints>b__1(EndpointRouteBuilderContext endpointContext) in D:\app\dotnet6\Backup\MyProject - 5.2\dashboard-master\src\MyProject.Web\HealthChecks\HealthChecksBuilderExtensions.cs:line 93 at Microsoft.AspNetCore.Builder.AbpAspNetCoreApplicationBuilderExtensions.<>c__DisplayClass0_0.<UseConfiguredEndpoints>b__0(IEndpointRouteBuilder endpoints) at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action1 configure) at Microsoft.AspNetCore.Builder.AbpAspNetCoreApplicationBuilderExtensions.UseConfiguredEndpoints(IApplicationBuilder app, Action`1 additionalConfigurationAction) at MyProject.Web.MyProjectWebModule.OnApplicationInitialization(ApplicationInitializationContext context) in D:\app\dotnet6\Backup\MyProject - 5.2\dashboard-master\src\MyProject.Web\MyProjectWebModule.cs:line 811 at Volo.Abp.Modularity.AbpModule.OnApplicationInitializationAsync(ApplicationInitializationContext context) at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.InitializeAsync(ApplicationInitializationContext context, IAbpModule module) at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context) --- End of inner exception stack trace --- at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context) at Volo.Abp.AbpApplicationBase.InitializeModulesAsync() at Volo.Abp.AbpApplicationWithExternalServiceProvider.InitializeAsync(IServiceProvider serviceProvider) at Microsoft.AspNetCore.Builder.AbpApplicationBuilderExtensions.InitializeApplicationAsync(IApplicationBuilder app) at MyProject.Web.Program.Main(String[] args) in D:\app\dotnet6\Backup\MyProject - 5.2\dashboard-master\src\MyProject.Web\Program.cs:line 40

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Is this work for you?

  • User Avatar
    0
    piseth created

    Hi,

    Is this work for you?

    Yes, it is working . I want to define it in appsettings. How to do that?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try this:

    {
        "HealthChecks":{
            "Name": "MyProjectName Health Status",
            "Uri": "https://xxxxxx/health-status"
          }
    }
    
    
    ....
    var configuration = services.GetConfiguration();
    ...
    
    var healthChecksUiBuilder = services.AddHealthChecksUI(settings =>
    {
        settings.AddHealthCheckEndpoint(configuration["HealthChecks:Name"], configuration["HealthChecks:Uri"]);
    });
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15