Base solution for your next web application

Activities of "[email protected]"

We are trying to scale up our application to run across multiple servers but are struggling to get this working.

Environment:

  • Docker Containers - AWS Fargate
  • AWS Application Load Balancers
  • Redis
  • Linux
  • Kestral (not IIS)

The problem seems to be around sharing the session information - I looked into it (there isn't much documentation for this so I could be wrong) and it would seem that sessions are just dealt with in the Cookies rather then storing them in a Cache?

From what I can see the Cache encryption/decryption is based off MachineKey which in an environment like above - changes every time a deploy is made (invalidating everyones sessions by making the cookies unreadable) and is different on every instance of the container.

I am trying to work out how to store this MachineKey so every container can encrypt/decrypt the cookies it looks like this is possible by using redis to store this: Microsoft.AspNetCore.DataProtection.Redis provides this ability but the Redis Setup is in Web.Core and the Cookie stuff seems to be handled by Web.Mvc (its the only thing that already has Microsoft.AspNetCore.DataProtection as part of cookies but adding: services.AddDataProtection().PersistKeysToRedis(); requires a redis connection that only exists in Web.core

Has anyone been able to sort this on there applications? It seems fundamental to 1. not clearing out sessions every time an application is deployed 2. scaling without running one BIG Server without load balancing and redudancy.

@ismcagdas - that seems to be purely related to PostgreSQL - I have said above we are using SQL Server Web Edition 14.00.3015.40.v1?

@ismcagdas SQL Server Web Edition 14.00.3015.40.v1

@alper Yes we are still seeing this pop up all the time - haven't got a fix yet.

@ismcagdas

  • AspNet Zero Version - v5.4.1

@ryancyq

  • it has been hard to reproduce but i am very sure the tenant id were the same...

I can't be sure cause it has been hard to reproduce in dev but NO.

AspNetZero - 5.4 AbpSession.TenantId was as expected and correct.

I have a theory - may be one you could correct me if not correct.

"If the application has not been accessed for 24 hours we would see this error appear and based on the log i think the cache still exist but the Cached objects (entity) are no longer present or corrupt. (I have only just been able to see the error my self for the first time today. hence the theory)"

Hopefully my theory makes sense

Sure. 1- This is just our test envrionment - so only one database host. 2 - No - there is no custom code around roles and or permissions tables.

Yes it does. Infact as soon as I clear the Cache from the Host Site... everything seems to be all good after until the next time.

There is no such an entity. Entity type: <tenant>.<companyurl>Authorization.Roles.Role

On our Test site (Tenant testing) - the user seems to be getting this error almost everytime they connect after a day or so... I have tried reproducing the error but am unable to reproduce. Also not so sure if the may be related to user session or memory caching. Any assistance\ pointer will be appriciated.

See attached logs

2455 [ERROR] Abp.AspNetCore.Mvc.ExceptionHandling.AbpExceptionFilter
> There is no such an entity. Entity type: <tenant>.<companyurl>.Authorization.Roles.Role, id: 5
Abp.Domain.Entities.EntityNotFoundException: There is no such an entity. Entity type: <tenant>.<companyurl>.Authorization.Roles.Role, id: 5
at Abp.Domain.Repositories.AbpRepositoryBase`2.&lt;GetAsync&gt;d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Threading.InternalAsyncHelper.&lt;AwaitTaskWithPostActionAndFinallyAndGetResult&gt;d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Roles.AbpRoleManager`2.&lt;&gt;c__DisplayClass46_0.&lt;&lt;GetRolePermissionCacheItemAsync&gt;b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Runtime.Caching.CacheExtensions.&lt;&gt;c__DisplayClass5_0`2.<<GetAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Runtime.Caching.CacheBase.<GetAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Runtime.Caching.CacheExtensions.<GetAsync>d__5`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Roles.AbpRoleManager`2.<GetRolePermissionCacheItemAsync>d__46.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Roles.AbpRoleManager`2.&lt;IsGrantedAsync&gt;d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Users.AbpUserManager`2.<IsGrantedAsync>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.Users.AbpUserManager`2.&lt;IsGrantedAsync&gt;d__34.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.PermissionChecker`2.<IsGrantedAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Authorization.PermissionChecker`2.&lt;IsGrantedAsync&gt;d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Web.Configuration.AbpUserConfigurationBuilder.&lt;GetUserAuthConfig&gt;d__43.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.Web.Configuration.AbpUserConfigurationBuilder.&lt;GetAll&gt;d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.&lt;GetAll&gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at lambda_method(Closure , Object )
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.&lt;InvokeNextActionFilterAsync&gt;d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.&lt;InvokeInnerFilterAsync&gt;d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;d__23.MoveNext()
Showing 1 to 10 of 10 entries