Thoughts?
** Our tech stack**:
** Question**: Our platform, which we build upon the ABP framework, serves two scenarios: the user access to functionality via an Angular-based portal that relies upon the backend APIs and offering API access for partners who don't want to use the portal but willing to access functionality we offer via the backend API layer. Now, we're facing another scenario where our clients want some sort of widget which is hosted on our end and can be embedded into their application. Their app is Angular as well. Way back, to fulfill scenarios like this, we used to develop responsive pages that could be embedded in somebody's app as an iFrame. My take on iFrames is simple - these days, this way of integration is treated as insecure. This is the context, and here's the list of questions I have and I hope you guys can help to address them:
Please advise.
hi
I debug the app, and it works.
Ok, I seem to have figured that out. I found a chunk of code in the HealthChecksBuilderExtensions.cs
:
var healthChecksUiBuilder = services.AddHealthChecksUI(settings =>
{
settings.AddHealthCheckEndpoint("_3M Health Status", $"http://{System.Net.Dns.GetHostName()}/health-status");
});
Whereas the right (default) value should have been this:
settings.AddHealthCheckEndpoint("_3M Health Status", healthCheckUrl);
NOTES:
It would be good for you guys to document it somewhere :)
It's strange. We never get such feedback.
- Can a new template project reproduce the problem on your computer?
- You can try your app on another computer
- You can try to use https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks directly without abp to see if the same problem exists
I think it's probably an environmental problem.
I tried on multiple devices and all of them show the same behavior. Can you try this code on your end?
Ok, Can you share the full logs when your app started?
liming.ma@volosoft.com
You can also change to
https://localhost:44338/health-status
and try again. : )
Tried that already and it didn't work. It picks up the machine hostname for some reason instead of the value from the config file. I just sent you the full log file to a specified address.
hi
The default URL in
appsettings.json
is"HealthCheckUrl": "/health-status"
Can you try to keep it as it is?
As I said in the explanation, I didn't change/tweak the configuration. The current value is "HealthCheckUrl": "/health-status"
To clarify - workstation0912
is my Windows 11 machine name. It's unclear why it resolves to this address if I run the Api.Host locally, instead of https://localhost:44338/health-status
, because this is exactly what I have defined in the appconfig.json file. I didn't change the config (except the connection string to a database). Am I missing any sort of configuration for Raider/Visual Studio???
[16:40:55 ERR] GetHealthReport threw an exception when trying to get report from http://WORKSTATION0912/health-status configured with name _3M Health Status.
System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (workstation0912:80)
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_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.HttpConnectionWaiter`1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.<SendAsync>g__Core|5_0(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendAsync>g__Core|5_0(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at HealthChecks.UI.Core.HostedService.HealthCheckReportCollector.GetHealthReportAsync(HealthCheckConfiguration configuration) in /_/src/HealthChecks.UI/Core/HostedService/HealthCheckReportCollector.cs:line 122
[16:40:55 DBG] HealthReportCollector - health report execution history saved.
[16:40:55 DBG] Creating a new HealthReport history.
[16:40:55 DBG] HealthReportCollector has completed.
[16:40:55 DBG] HealthCheck collector HostedService executed successfully.
[16:41:05 DBG] Executing HealthCheck collector HostedService.
[16:41:05 INF] Start processing HTTP request GET http://workstation0912/health-status
[16:41:05 INF] Sending HTTP request GET http://workstation0912/health-status
[16:41:17 ERR] GetHealthReport threw an exception when trying to get report from http://WORKSTATION0912/health-status configured with name _3M Health Status.
System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (workstation0912:80)
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|281_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.HttpConnectionWaiter`1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.<SendAsync>g__Core|5_0(HttpRequestMessage request, CancellationToken cancellationToken)
at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.<SendAsync>g__Core|5_0(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsC
Hi,
You can try:
var builder = WebApplication.CreateBuilder(args); builder.WebHost.UseSentry(); builder.Host .AddAppSettingsSecretsJson() .UseAutofac() .UseSerilog(); await builder.AddApplicationAsync<MyProjectNameWebPublicModule>(); var app = builder.Build(); app.UseSentryTracing(); await app.InitializeApplicationAsync(); await app.RunAsync(); return 0;
This configuration worked (I saw from the logs it was initializing) but it didn't send transactions to Sentry. I got in contact with Sentry support, and theit support suggested making a change to appsettings,json
to include "TracesSampleRate": "1.0"
parameter. My config started looking like this:
It worked like a charm.
Thanks for the help.
Steps to reproduce:
appsettings.json
file in the 'xxx.HttpApi.Host' (backend) project.Program.cs
like this:var builder = WebApplication.CreateBuilder(args);
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
await builder.AddApplicationAsync<_3MHttpApiHostModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();
app.UseSentryTracing();
return 0;
etc/build/build-images-locally.ps1
etc/docker/run-docker.ps1
Another question:
The official documentation from Sentry suggests using builder.WebHost.UseSentry();
construction. However, the ABP code does not use WebHost
. Is there a workaround for that?
Please advise.
hi
Are there any error logs on the backend app?
The only error message I see in the backend is this: 2023-04-26 21:56:31 [01:56:31 INF] OpenIddict.Validation.AspNetCore was not authenticated. Failure message: An error occurred while authenticating the current request.
See more in the full log: https://1drv.ms/t/s!AtmlF7r3uFNtj7J8AlcWTvdp4Fp6aQ?e=VwBs9t