Base solution for your next web application
Open Closed

Site stopped working after every 1-2 days #12003


User avatar
0
huntethan89 created

Hi,

I have my application in MVC asp.net core. My site is published on IIS. It keeps stop working after 1 or 2 days. After that i have to restart my IIS and site starts working again. I checked my logs and found the following error. Can someone please help me with this error:

ERROR 2024-05-15 08:21:59,482 [340 ] e.Diagnostics.ExceptionHandlerMiddleware - An unhandled exception has occurred while executing the request. System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at Microsoft.Data.SqlClient.SqlConnection.Open() at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected) at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.BeginTransaction(IsolationLevel isolationLevel) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func3 operation, Func3 verifySucceeded) at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.BeginTransaction(DatabaseFacade databaseFacade, IsolationLevel isolationLevel) at Abp.EntityFrameworkCore.Uow.DbContextEfCoreTransactionStrategy.CreateDbContext[TDbContext](String connectionString, IDbContextResolver dbContextResolver) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.GetOrCreateDbContext[TDbContext](Nullable1 multiTenancySide, String name) at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.get_Table() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.Insert(TEntity entity) at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.InsertAsync(TEntity entity) at Castle.Proxies.Invocations.IRepository2_InsertAsync_29.InvokeMethodOnTarget() at Castle.DynamicProxy.AbstractInvocation.Proceed() at Castle.DynamicProxy.AbstractInvocation.ProceedInfo.Invoke() at Abp.Domain.Uow.UnitOfWorkInterceptor.InternalInterceptAsynchronous[TResult](IInvocation invocation) at Abp.Auditing.AuditingHelper.SaveAsync(AuditInfo auditInfo) at Abp.AspNetCore.Mvc.Auditing.AbpAuditActionFilter.OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) 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() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeNextResourceFilter() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) at IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Abp.AspNetZeroCore.Web.Authentication.JwtBearer.JwtTokenMiddleware.<>c__DisplayClass0_0.<<UseJwtTokenMiddleware>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

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

    Hi @huntethan89

    Could you share your final Startup.cs ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    Please check the attached link for startup.cs file.

    https://smartlayer-my.sharepoint.com/:u:/g/personal/hsharma_smartlayer_ca/EaPgevyTiQVBg05sqQgJpFMBMb234iDFIAWnSQPico6-Kg?e=1VirsC

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @huntethan89

    Your Startup file seems fine. Is it possible to share your latest source code with [email protected] ? We will investigate your project to detect possible causes.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    Sorry for the delay. But i think its working now. We got issue only one time after upgrading version. I will keep monitoring and if found any issues i will post again.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi

    Thank you for the update! I’m glad it’s working now. Please keep monitoring and don’t hesitate to let us know if you encounter any further issues.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    It happened again yesterday. The site was down again and we got same error. I am attaching logs, please have a look.

    https://smartlayer-my.sharepoint.com/:t:/g/personal/hsharma_smartlayer_ca/ERsniNssRPtLvf1zpYxv4JwBlSGp_YXL_XEhsrg6gsae4A?e=XDbME7

    Thanks.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @huntethan89

    Is it possible for you to share your project's latest version with [email protected] ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @huntethan89,

    Please refactor your async void codes to async Task.

    If you have async overload of methods please use async methods instead of sync methods.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    My account was not working. Now its updated. I will check the solution you provided and get back to you.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @huntethan89

    After checking the situation, let me know if you need any further assistance. Thank you.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    We made changes as suggested in our project. We pushed the changes on live and now monitoring from last 3-4 days. It did not give error so far. We will keep monitor closely for another week when there is heavy traffic on website. I will let you know if there will be any issue.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @huntethan89

    Thanks for the update. I'm glad to hear that the changes are working well so far. Please feel free to reach out if any issues arise. I'll be here if you need any further assistance.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    The same issue occurred again yesterday. The site was down—please help us resolve this issue

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    As part of our ongoing investigation into the application crashes, we noticed that on 28th April, the following error appeared in the audit logs at 12:06:25.7914840:

    Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.

    For context, we've gathered:

    1. Audit log data between 12:05 and 12:08 on 28th April, including method names, exception messages, execution times, and durations.

    1. Request counts per minute on the peak time for same day to highlight any spikes around the crash.

    Based on this information, is it possible that the application crash was caused by reaching the maximum connection pool size?

    Please let us know if you require any additional information.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @huntethan89

    In order to examine the situation you are experiencing in more detail, could you share your latest project and the logs and error messages you receive in the live environment by sending them to [email protected]? We will analyze this information and try to determine the source of the problem.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    As requested, We have shared the project along with app logs to [email protected].

    Please check and let me know if more infromation required.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thank you for sharing your project. It seems like you are using sync version of security token handler in WeiglCentralSystemDemoJwtSecurityTokenHandler. This is changed in the later versions of AspNet Zero. You can change it by looking at https://github.com/aspnetzero/aspnet-zero-core/commit/93ef2723884219ab087ba51521a261aa0708cdd0

    For the initial implementation, you can take a look at;

    Another suggesstion is, you can remove usages of AsyncHelper as much as possible.

    I hope these two enhancements will help.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    huntethan89 created

    Hi,

    I am trying to open these github links but its showing page not found. Can you please if my email has still access to repository or not. I sent my email which had access in the same email in which i shared my project.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @huntethan89

    After logging in with the user who has the plan on the aspnetzero.com website, clicking the manage button under the Account button, you can give permission to the github user you are trying to log in from the Github Members tab on the relevant page. Additionally, we saw that you reported the same issue via email, and a response has been provided there as well.

    Thank you

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)