Timeouts

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
2 years ago
Hi. My client is having issues with timeouts - this morning we could not access the admin of the site and the nopcommerce log has multiple entries like the following. The site is running on a vps which has a 3GHz processor, 6gb ram and 120gb disk space. The only way to get the site running again is by doing a reboot. The server is running windows. Could this be a hosting issue with the provider as the spec of the VPS should be more than adequate.

System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
   at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__126_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at LinqToDB.Data.DataConnection.ExecuteReaderAsync(CommandBehavior commandBehavior, CancellationToken cancellationToken)
   at LinqToDB.Data.DataConnection.QueryRunner.ExecuteReaderAsync(CancellationToken cancellationToken)
   at LinqToDB.Linq.QueryRunner.ExecuteElementAsync[T](Query query, IDataContext dataContext, Mapper`1 mapper, Expression expression, Object[] ps, Object[] preambles, CancellationToken cancellationToken)
   at LinqToDB.Linq.ExpressionQuery`1.LinqToDB.Async.IQueryProviderAsync.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
   at System.Linq.AsyncIQueryableExtensions.ToPagedListAsync[T](IQueryable`1 source, Int32 pageIndex, Int32 pageSize, Boolean getOnlyTotalCount)
   at Nop.Services.Orders.OrderReportService.BestSellersReportAsync(Int32 categoryId, Int32 manufacturerId, Int32 storeId, Int32 vendorId, Nullable`1 createdFromUtc, Nullable`1 createdToUtc, Nullable`1 os, Nullable`1 ps, Nullable`1 ss, Int32 billingCountryId, OrderByEnum orderBy, Int32 pageIndex, Int32 pageSize, Boolean showHidden)
   at Nop.Web.Components.HomepageBestSellersViewComponent.<InvokeAsync>b__9_0()
   at Nop.Core.Caching.MemoryCacheManager.GetAsync[T](CacheKey key, Func`1 acquire)
   at Nop.Web.Components.HomepageBestSellersViewComponent.InvokeAsync(Nullable`1 productThumbPictureSize)
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsyncCore(ObjectMethodExecutor executor, ViewComponentContext context)
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentInvoker.InvokeAsync(ViewComponentContext context)
   at Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentHelper.InvokeCoreAsync(ViewComponentDescriptor descriptor, Object arguments)
   at AspNetCore.Views_Home_Index.ExecuteAsync() in C:\WebRoot\nopCommerce2022\Views\Home\Index.cshtml:line 36
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultFilters>g__Awaited|27_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   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>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at WebMarkupMin.AspNetCore5.WebMarkupMinMiddleware.ProcessAsync(HttpContext context, Boolean useMinification, Boolean useCompression)
   at WebMarkupMin.AspNetCore5.WebMarkupMinMiddleware.ProcessAsync(HttpContext context, Boolean useMinification, Boolean useCompression)
   at WebMarkupMin.AspNetCore5.WebMarkupMinMiddlewareBase.Invoke(HttpContext context)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 125
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Nop.Services.Authentication.AuthenticationMiddleware.InvokeAsync(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Nop.Services.Installation.InstallUrlMiddleware.InvokeAsync(HttpContext context, IWebHelper webHelper)
   at Nop.Services.Common.KeepAliveMiddleware.InvokeAsync(HttpContext context, IWebHelper webHelper)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
ClientConnectionId:2b22ded1-2879-4d79-bbf0-d1982a33f214
Error Number:-2,State:0,Class:11
2 years ago
RE: SqlException : Timeout expired.

That's a SQL timeout.  Where is your SQL Server?  Is it on the same PC as the web site?

The trace shows that you are running the "BestSellersReport...". Do you see logged errors for SQLException / timeout for other 'features'?

I believe the SQL timeout defaults to 30 seconds.  You can alter that by adding, e.g. this
;Connection Timeout=60
to the end of your ConnectionString (in appsettings.json, and then restart the site)
2 years ago
Oh, I just remembered, that's the 'connection' timeout, not the CommandTimeout.  You can try it anyway.   I'm not sure that the latter can be adjusted in settings.  I'll check.
2 years ago
Oh, silly me ;)   it's right there in appsettings.json
  "ConnectionStrings": {
    "ConnectionString": "Data Source=localhost;Initial Catalog=nopCommerce450_sample;Integrated Security=True;Persist Security Info=False;Trust Server Certificate=True",
    "DataProvider": "sqlserver",
    "SQLCommandTimeout": null
  },



Just change 'null' to e.g. 60
2 years ago
Thanks NY. I have changed it in Datasettings.json - I can't see it in app settings.json.

Ive cleared the log now so can't check previous errors but can I turn off best sellers? and anything else that could be causing this? Thanks
2 years ago
What's your version of nopCommerce?
2 years ago
4.40
2 years ago
In file  \Areas\Admin\Views\Home\Index.cshtml, on line 110 is
                    @if (canManageOrders)
if you change that to
                    @if (false and canManageOrders)
it will prevent showing the report in the admin home page.
2 years ago
Hi! You can also look at the solution to the problem with BestsellersBriefReports in this ticket, if you have access to the source code you can fix the problem yourself. If changing the query timeout doesn't fix the underlying issue, please share the new log entries.

jimbobmattison wrote:
Thanks NY. I have changed it in Datasettings.json - I can't see it in app settings.json.

Ive cleared the log now so can't check previous errors but can I turn off best sellers? and anything else that could be causing this? Thanks
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.