Base solution for your next web application
Open Closed

HealthCheck UI #11767


User avatar
-1
daniela.buttner created

Hi

I am getting an exception due to HealthChecks Ui. The Json Api Health works fine.

Regards

ERROR 2023-11-06 10:04:53,513 [11 ] HostedService.HealthCheckReportCollector - GetHealthReport threw an exception when trying to get report from https://localhost:44302/health configured with name Badger.Web.MVC. System.Text.Json.JsonException: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0. ---> System.Text.Json.JsonReaderException: '<' is an invalid start of a value. LineNumber: 0 | BytePositionInLine: 0. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes) at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker) at System.Text.Json.Utf8JsonReader.ReadFirstToken(Byte first) at System.Text.Json.Utf8JsonReader.ReadSingleSegment() at System.Text.Json.Utf8JsonReader.Read() at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) --- End of inner exception stack trace --- at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex) at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo) at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsyncCore[T](HttpContent content, Encoding sourceEncoding, JsonSerializerOptions options, CancellationToken cancellationToken) at HealthChecks.UI.Core.HostedService.HealthCheckReportCollector.GetHealthReportAsync(HealthCheckConfiguration configuration) in /_/src/HealthChecks.UI/Core/HostedService/HealthCheckReportCollector.cs:line 126

Update and my Insomnia has this error.


10 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @daniela.buttner

    Could you also share your AspNet Zero version ?

    Thanks,

  • User Avatar
    0
    daniela.buttner created

    HI

    we use the 12.1.0 / Core MVC & JQuery

    Regards

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I couldn't find any problem related to this. Could you try upgrading your HealthCheck NuGet packages ? If that doesn't work, is it possible to share your project with [email protected] for us to check ?

  • User Avatar
    0
    daniela.buttner created

    Hi

    I upgrade the NuGet packages but the same problem.

    In my initial request I push a screen from an Insomia post request, and on this I get a Unauthorized error. Why that or how can I fix this problem?

    We test it with 2 Server, on the Test Server it works on the Prod Server doesn't work. The reason is on Test Server, the IIS Authentication -> Anonymous Authentication is enabled and on the other Server not. But we not allow Anonymous Authentication.

    You have a solution for this problem?

    Regards

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Probably I got the problem wrong at first. Are you having this problem only for your custom check ? If so, is it possible to share its code ?

  • User Avatar
    0
    daniela.buttner created

    Hi

    no in this screen shot you can see, I activate the cache health only. The Prod und Staging Server running without allow anonymous and the Dev Server we activate the IIS Configuration allow anonymous.

    Regards

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thanks. Is it at least possible to share your custom healtcheck class ? We are not able to reproduce this on our side. I think it will help us.

  • User Avatar
    0
    daniela.buttner created

    Hi

    thats from the last exapmle

    public static class AbpZeroHealthCheck { public static IHealthChecksBuilder AddAbpZeroHealthCheck(this IServiceCollection services) { var builder = services.AddHealthChecks(); // builder.AddCheck<BadgerMetaDbContextHealthCheck>("Meta Database Connection"); // builder.AddCheck<BadgerMetaDbContextUsersHealthCheck>("Database Connection with user check"); builder.AddCheck<CacheHealthCheck>("Cache");

            //Und ACHTUNG the Name is unique!!!
            
            // add your custom health checks here
            // builder.AddCheck&lt;MyCustomHealthCheck&gt;("my health check");
            // builder.AddCheck&lt;BadgerAppDataDbContextHealthCheck&gt;("App Database Connection");
            // builder.AddCheck&lt;BadgerMongoDbContextHealthCheck&gt;("Mongo Database Connection");
            
            return builder;
        }
    }
    

    and this is a custom healtcheck class

    namespace Badger.HealthChecks { public class BadgerAppDataDbContextHealthCheck : IHealthCheck { private readonly DatabaseCheckHelper _checkHelper;

        public BadgerAppDataDbContextHealthCheck(DatabaseCheckHelper checkHelper)
        {
            _checkHelper = checkHelper;
        }
    
        public Task&lt;HealthCheckResult&gt; CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken())
        {
            if (_checkHelper.Exist(BadgerConsts.AppDataConnectionStringName))
            {
                return Task.FromResult(HealthCheckResult.Healthy("BadgerAppDataDbContext connected to database."));
            }
    
            return Task.FromResult(HealthCheckResult.Unhealthy("BadgerAppDataDbContext could not connect to database"));
        }
    }
    

    }

    namespace Badger.HealthChecks { public class BadgerMongoDbContextHealthCheck : IHealthCheck { private readonly DatabaseCheckHelper _checkHelper;

        public BadgerMongoDbContextHealthCheck(DatabaseCheckHelper checkHelper)
        {
            _checkHelper = checkHelper;
        }
    
        public Task&lt;HealthCheckResult&gt; CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken())
        {
            if (_checkHelper.Exist(BadgerConsts.MongoDbConnectionStringName))
            {
                return Task.FromResult(HealthCheckResult.Healthy("BadgerMetaDbContext connected to database."));
            }
    
            return Task.FromResult(HealthCheckResult.Unhealthy("BadgerMetaDbContext could not connect to database"));
        }
    }
    

    }

    Regards

  • User Avatar
    0
    daniela.buttner created

    Hallo

    there are any news to this problem?

    Regards

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @daniela.buttner

    Sorry, we couldn't reproduce this problem on our side. Is it possible to access your Staging Server and test this ?