Open Closed

Error making requests to /api/abp/application-localization and /api/abp/application-configuration #8811


User avatar
0
dw-cce created
  • ABP Framework version: v9.0
  • UI Type: MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
2025-01-30 00:07:47.653 +00:00 [INF] Request starting HTTP/1.1 GET https://api.myapp.com/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - null null 2025-01-30 00:07:47.654 +00:00 [INF] Executing endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)' 2025-01-30 00:07:47.654 +00:00 [INF] Route matched with {area = "abp", action = "Get", controller = "AbpApplicationConfiguration", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationDto] GetAsync(Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ApplicationConfigurationRequestOptions) on controller Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController (Volo.Abp.AspNetCore.Mvc).
2025-01-30 00:07:47.657 +00:00 [INF] Executing action method Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) - Validation state: "Valid"
2025-01-30 00:07:47.662 +00:00 [INF] Authorization failed. These requirements were not met:
PermissionRequirement: Project.Project.Edit
2025-01-30 00:07:47.662 +00:00 [INF] Authorization failed. These requirements were not met:
PermissionRequirement: Project.Project.ScheduleEdit
2025-01-30 00:07:47.662 +00:00 [INF] Authorization failed. Fail() was explicitly called.
2025-01-30 00:07:47.662 +00:00 [WRN] The operation was canceled.
System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAsync(String key, CancellationToken token)
at Volo.Abp.Caching.DistributedCache`2.GetAsync(TCacheKey key, Nullable`1 hideErrors, Boolean considerUow, CancellationToken token)
2025-01-30 00:07:47.664 +00:00 [ERR] An error occurred using the connection to database 'sqldb-myapp' on server 'sql-myserver.database.windows.net'.
2025-01-30 00:07:48.172 +00:00 [ERR] ---------- RemoteServiceErrorInfo ----------
{
"code": null,
"message": "An internal error occurred during your request!",
"details": null,
"data": null,
"validationErrors": null
}

2025-01-30 00:07:48.172 +00:00 [ERR] A task was canceled.
System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at Volo.Abp.FeatureManagement.EntityFrameworkCore.EfCoreFeatureValueRepository.GetListAsync(String providerName, String providerKey, CancellationToken cancellationToken)
at Castle\.DynamicProxy\.AsyncInterceptorBase\.ProceedAsynchronous\[TResult\]\(IInvocation invocation\, IInvocationProceedInfo proceedInfo\)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Volo.Abp.FeatureManagement.FeatureManagementStore.SetCacheItemsAsync(String providerName, String providerKey, String currentName, FeatureValueCacheItem currentCacheItem) at Volo.Abp.FeatureManagement.FeatureManagementStore.GetCacheItemAsync(String name, String providerName, String providerKey) at Volo.Abp.FeatureManagement.FeatureManagementStore.GetOrNullAsync(String name, String providerName, String providerKey) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.Features.TenantFeatureValueProvider.GetOrNullAsync(FeatureDefinition feature)
at Volo.Abp.Features.FeatureChecker.GetOrNullValueFromProvidersAsync(IEnumerable`1 providers, FeatureDefinition feature) at Volo.Abp.Features.FeatureChecker.GetOrNullAsync(String name) at Volo.Abp.Features.FeatureCheckerBase.IsEnabledAsync(String name) at Volo.Abp.Features.FeatureCheckerExtensions.IsEnabledAsync(IFeatureChecker featureChecker, Boolean requiresAll, String[] featureNames) at Volo.Abp.Features.RequireFeaturesSimpleStateChecker`1.IsEnabledAsync(SimpleStateCheckerContext`1 context) at Volo.Abp.SimpleStateChecking.SimpleStateCheckerManager`1.InternalIsEnabledAsync(TState state, Boolean useBatchChecker)
at Volo.Abp.SimpleStateChecking.SimpleStateCheckerManager`1.IsEnabledAsync(TState state) at Volo.Abp.Authorization.Permissions.PermissionChecker.IsGrantedAsync(ClaimsPrincipal claimsPrincipal, String[] names) at Volo.Abp.Authorization.Permissions.PermissionChecker.IsGrantedAsync(String[] names) at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAuthConfigAsync() at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationAppService.GetAsync(ApplicationConfigurationRequestOptions options) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle\.DynamicProxy\.AsyncInterceptorBase\.ProceedAsynchronous\[TResult\]\(IInvocation invocation\, IInvocationProceedInfo proceedInfo\)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Castle\.DynamicProxy\.AsyncInterceptorBase\.ProceedAsynchronous\[TResult\]\(IInvocation invocation\, IInvocationProceedInfo proceedInfo\)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed) at Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync(ApplicationConfigurationRequestOptions options) at lambda_method2653(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2025-01-30 00:07:48.172 +00:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'. 2025-01-30 00:07:48.173 +00:00 [INF] Executed action Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc) in 518.3966ms 2025-01-30 00:07:48.173 +00:00 [INF] Executed endpoint 'Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.AbpApplicationConfigurationController.GetAsync (Volo.Abp.AspNetCore.Mvc)' 2025-01-30 00:07:48.200 +00:00 [INF] Request finished HTTP/1.1 GET https://api.myapp.com/api/abp/application-configuration?IncludeLocalizationResources=False&api-version=1.0 - 500 null application/json; charset=utf-8 546.3452ms`
  • Steps to reproduce the issue:

We have just upgraded from ABP v4.4 to v9.0, deployed to production and monitored the logs. In the log for the API the request above was made every 5 mins since deployment and then after 8+ hours became less frequent. We can see in the logs for our test environment that the same requests were made at 5 minute intervals. This also happens when no users are in the app.

I have seen some other users with the same or similar issues, but they are closed without any resolution noted.

Are there any processes that run on a 5 minute interval that could cause this? How can we debug this to find the root cause? It doesn't seem to happen when running the app locally.

I have already reported this issue under - https://abp.io/support/questions/8723/Error-making-requests-to-apiabpapplication-localization-and-apiabpapplication-configuration

It was closed before I was able to test in production. The suggested fix has not resolved the issue.


7 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Hi,

    The only log that I can found in your logs is An error occurred using the connection to database 'sqldb-myapp' on server 'sql-myserver.database.windows.net'.

    Is your SqlServer version, or nuget package sqlserver version changed? Is there any chance, latest EntityFrameworkCore prover don't support your database version?

    Also there can be different errors too.

    Do you still use IdentityServer or migrated to OpenIdDict?

    And you mentioned your solution is tiered. Do this logs belong to HttpApi.Host project?

  • User Avatar
    0
    dw-cce created

    Hi enisn,

    We haven't changed the database, we are using the same SQL Azure database that we were using with ABP v4.4. The EF package will have been updated to the ABP 9.0 package.

    As part of the update from ABP v4.4 to ABP v9.0 we migrated from IdentityServer to OpenIddict using your migration guide.

    Yes, this log is from the HttpApi.Host project. The API is not used much at the moment, we have a mobile app that calls some services, and some parts of the app use the JavaScript proxies, but the majority of our app services are called from Razor pages code behind.

    Please let me know if you need more information.

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    The problem occurs while executing SimpleStateCheckerManager.IsEnabled call but I can't be sure the real reason for the. Surely it's a connection issue between your app and the database but there is no specific reason. System.Threading.Tasks.TaskCanceledException was thrown on your case. There might be a timeout during this request. We should check if it's timeout or not.

    Can you try setting a manual timeout in your DbContext?

    // constructor
    public YourAppDbContext(DbContextOptions<YourAppDbContext> options) : base(options)
    {
        Database.SetCommandTimeout(TimeSpan.FromSeconds(60)); // Or more
    }
    

    TaskCanceledException can be thrown in different ways, we can determine the exact reason by eliminating options

  • User Avatar
    0
    dw-cce created

    Hi ensin,

    Can you explain a bit more about what I'm looking for here? I can change this for our test environment but I'm not sure I want to push it to prod. Are we assuming if the problem goes away it was a timeout issue? If so, what is the next step?

  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    It's hard to understand the problem right no with this information. More detailed logs or debugging might be required. You're encountering a complex issue involving authorization failures, database connection problems, and potential caching issues within your application. Let's break down the problem and outline a systematic approach to debugging and resolving it.

    Understanding the Problem

    1. Authorization Failures:

    • The logs clearly show authorization failures:
      • PermissionRequirement: Project.Project.Edit
      • PermissionRequirement: Project.Project.ScheduleEdit
    • This indicates that the application is attempting to check permissions, even when requesting application configuration.
    • The fact that this happens for api/abp/application-configuration which is normally available to all users is very strange.

    2.Database Connection Issues:

    • The logs report database connection errors:
      • An error occurred using the connection to database 'sqldb-myapp' on server 'sql-myserver.database.windows.net'.
      • System.Threading.Tasks.TaskCanceledException: A task was canceled.
    • These errors suggest that the application is trying to access the database, but the connection is being canceled or failing. This is happening during the feature management store call.
    • This is happening during the feature management store call which is called to check feature permissions.

    3.Caching Issues:

    • System.OperationCanceledException: The operation was canceled.
    • at Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache.GetAsync(String key, CancellationToken token)
    • This indicates that a cached request to redis was cancelled. This is likely linked to the database connection issues.

    4. Recurring Requests:

    • The requests occur at 5-minute intervals, pointing to a potential background task or scheduled operation.

    Debugging Steps

    1. Identify the Source of the Recurring Requests

    • Scheduled Tasks: Check your application for any scheduled tasks or background jobs that might be making these requests. Look for BackgroundJobManager, IBackgroundJob, or similar implementations.
    • External Monitoring: Verify that no external monitoring tools or health checks are configured to make these requests.
    • Client-Side Code: although unlikely, check any client side javascript code for any calls to the application configuration endpoint. Middleware: Check for custom middleware that might be making these calls.

    2. Investigate Authorization Issues:

    • Permission Configuration: Review your permission configuration (PermissionDefinitionProvider) to ensure that Project.Project.Edit and Project.Project.ScheduleEdit are correctly defined.
    • Feature Checks: The stack trace indicates that FeatureChecker is involved. Investigate your feature definitions and how they are used in conjunction with permissions.
    • Authentication: Ensure that your authentication setup is correct. If the application is incorrectly trying to authenticate, it might be triggering permission checks.
    • Override AbpApplicationConfigurationAppService: Override the GetAuthConfigAsync method within your application's AbpApplicationConfigurationAppService to log the current user's claims and permissions. This can help you understand why authorization is failing.

    3. Diagnose Database Connection Problems:

    • Connection String: Double-check your database connection string for accuracy.
    • Database Server Health: Monitor the health of your SQL Server instance, including CPU, memory, and disk usage. Connection Limits: Verify that you are not exceeding connection limits on your database server.
    • Transient Fault Handling: Implement transient fault handling (e.g., using Polly) to retry database operations after temporary connection failures.
    • EntityFramework Core Logging: Enable detailed EF Core logging to get more information about the database queries and connection attempts.

    4. Analyze Caching Behavior:

    • Redis Health: Check the health of your Redis server.
    • Redis Configuration: Verify your Redis configuration, including connection timeouts and other settings.
    • Caching Keys: Log the caching keys being used to identify any patterns or issues.
    • Disable Caching Temporarily: Temporarily disable Redis caching to see if the database connection issues persist. This will help isolate the problem.

    5. Environment Differences:

    • Configuration: Compare the configuration files and environment variables between your local, test, and production environments. Pay close attention to database connection strings, caching settings, and feature flags.
    • Infrastructure: Investigate any differences in infrastructure between your environments, such as network latency, load balancers, or firewalls.

    Code Example (Overriding GetAuthConfigAsync)

    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Authorization;
    using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations;
    using Volo.Abp.DependencyInjection;
    using Microsoft.AspNetCore.Http;
    using System.Linq;
    using Microsoft.Extensions.Logging;
    using Microsoft.Extensions.Options;
    using Volo.Abp.Localization;
    using Volo.Abp.MultiTenancy;
    using Volo.Abp.Authorization;
    using Volo.Abp.Authorization.Permissions;
    using Volo.Abp.Users;
    using Volo.Abp.Settings;
    using Volo.Abp.Features;
    using Volo.Abp.Timing;
    using Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations.ObjectExtending;
    
    namespace YourProject.Controllers
    {
        [Dependency(ReplaceServices = true)]
        [ExposeServices(typeof(IAbpApplicationConfigurationAppService), typeof(AbpApplicationConfigurationAppService))]
        public class CustomAbpApplicationConfigurationAppService : AbpApplicationConfigurationAppService
        {
            private readonly ILogger<CustomAbpApplicationConfigurationAppService> _logger;
            private readonly IHttpContextAccessor _httpContextAccessor;
    
            public CustomAbpApplicationConfigurationAppService(IOptions<AbpLocalizationOptions> localizationOptions,
                IOptions<AbpMultiTenancyOptions> multiTenancyOptions,
                IServiceProvider serviceProvider,
                IAbpAuthorizationPolicyProvider abpAuthorizationPolicyProvider,
                IPermissionDefinitionManager permissionDefinitionManager,
                DefaultAuthorizationPolicyProvider defaultAuthorizationPolicyProvider,
                IPermissionChecker permissionChecker,
                IAuthorizationService authorizationService,
                ICurrentUser currentUser,
                ISettingProvider settingProvider,
                ISettingDefinitionManager settingDefinitionManager,
                IFeatureDefinitionManager featureDefinitionManager,
                ILanguageProvider languageProvider,
                ITimezoneProvider timezoneProvider,
                IOptions<AbpClockOptions> abpClockOptions,
                ICachedObjectExtensionsDtoService cachedObjectExtensionsDtoService,
                IOptions<AbpApplicationConfigurationOptions> options,
                ILogger<CustomAbpApplicationConfigurationAppService> logger,
                IHttpContextAccessor httpContextAccessor) : base(localizationOptions, multiTenancyOptions, serviceProvider, abpAuthorizationPolicyProvider, permissionDefinitionManager, defaultAuthorizationPolicyProvider, permissionChecker, authorizationService, currentUser, settingProvider, settingDefinitionManager, featureDefinitionManager, languageProvider, timezoneProvider, abpClockOptions, cachedObjectExtensionsDtoService, options)
            {
                _logger = logger;
                _httpContextAccessor = httpContextAccessor;
            }
    
            protected override async Task<ApplicationAuthConfigurationDto> GetAuthConfigAsync()
            {
                _logger.LogInformation("Custom GetAuthConfigAsync called.");
    
                var httpContext = _httpContextAccessor.HttpContext;
                if (httpContext?.User?.Claims != null)
                {
                    _logger.LogInformation("User Claims:");
                    foreach (var claim in httpContext.User.Claims)
                    {
                        _logger.LogInformation($"Claim Type: {claim.Type}, Value: {claim.Value}");
                    }
                }
                if(httpContext != null){
                    _logger.LogInformation("User authenticated: " + httpContext.User.Identity.IsAuthenticated);
                }
    
                var authConfig = await base.GetAuthConfigAsync();
                return authConfig;
            }
        }
    }
    
  • User Avatar
    0
    dw-cce created

    Thanks enisn, I'll work through these.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Thanks enisn, I'll work through these.

    Thanks, we will be waiting for your reply.

    Regards.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 25, 2025, 11:10