Xabaril / AspNetCore.Diagnostics.HealthChecks

Enterprise HealthChecks for ASP.NET Core Diagnostics Package
Apache License 2.0
4.12k stars 800 forks source link

Error while copying content to a stream #2241

Closed EdwinThomas11 closed 5 months ago

EdwinThomas11 commented 5 months ago

Hello,

I hope you're doing well.

I'm working on implementing a health check in my application. Here are the changes I've made.

Here is the code in the startup.cs

services.AddHealthChecks() .AddSqlServer("MyConnectionString");

services .AddHealthChecksUI(s => { s.AddHealthCheckEndpoint("endpoint1", "https://localhost:5001/health"); }) .AddInMemoryStorage();

app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapHealthChecksUI(); endpoints.MapHealthChecks("https://localhost:5001/health", new HealthCheckOptions() { Predicate = _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); });

Here is the package references: image

Here is the json health check: image

Here is the health check UI: image

I'm not sure why I'm encountering this error ("Unexpected character encountered while parsing value: <. Path '', line 0, position 0.") in the health check UI.

I would appreciate any help you can provide.

Regards, Edwin Thomas

EdwinThomas11 commented 5 months ago

@adamsitnik, @Jamie-Clayton Appreciate your help here.

dbarwikowski commented 5 months ago

Could you show screenshot from dev tools, network tab? I'm interested in contents of /healthchecks-api request

EdwinThomas11 commented 5 months ago

@dbarwikowski Please find the screenshot for your response

image
dbarwikowski commented 5 months ago

Thanks! Unfortunately it's not helpful :( One more think that might be a problem is https. Is your API setup to use it?

EdwinThomas11 commented 5 months ago

@dbarwikowski The issue was due to the authorization for https://localhost:5001/health. After whitelisting this URL, it worked as expected.

EdwinThomas11 commented 5 months ago

https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks/issues/2255 -> Another ticket for reference. CC : @dbarwikowski

dbarwikowski commented 4 months ago

I've seen the other issue of yours. Is this still a problem?