Dropping SQL connection

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hello Guys,

I know this error seems pretty standard, but it is driving me crazy. Since I updated to 4.1 from 3.7 I'm receiving this error. I need to restart the whole site to make it work again. It occurs in 5 minutes to 5 days, so no one knows when will be the whole site down again. Any idea what is the root cause of this?:

`info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
      Entity Framework Core 2.1.1-rtm-30846 initialized 'NopObjectContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer' with options: using lazy-loading proxies
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
      An error occurred using the connection to database 'databasename' on server 'sqlserver location'.
System.Data.SqlClient.SqlException (0x80131904): Connection Timeout Expired.  The timeout period elapsed during the post-login phase.  The connection could have timed out while waiting for server to complete the login process and respond; Or it could have timed out while attempting to create multiple active connections.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=89; handshake=99; [Login] initialization=21; authentication=27; [Post-Login] complete=14047;  ---> System.ComponentModel.Win32Exception (258): The wait operation timed out
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)`
5 years ago
It's likely some problem with your SQL Server.  See this
https://stackoverflow.com/questions/1421978/help-troubleshooting-sqlexception-timeout-expired-on-connection-in-a-non-load
5 years ago
Thanks, will take a closer look on the infrastructure, however we are using SQL 2012 and not SQL 2008, I don't know if this error is still happens on 2012.
5 years ago
+info:

in stdout log, all the "everything ok" logs are ending with: "Application is shutting down..." then the next log file will start with the exception
5 years ago
Sorry for the number of replies, but + info for the logs: so an "everything ok" log ends with this:


      Request starting HTTP/1.1 POST http://127.0.0.1:12485/iisintegration  0
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 0.3152ms 202
Application is shutting down...


Keep alive task should run in every 300 seconds.
5 years ago
If "Application is shutting down", then that could be a different issue than SQL Server timeout.  (Do you have enough memory in your IIS server?  is your SQL DB running on the same server as IIS? [not a good idea])  

This may interest you, but I believe the issue was fixed in 4.10:

https://www.nopcommerce.com/boards/t/49851/serious-iis-application-pool-recycling-bugdesign-flaw.aspx?p=4#199793
5 years ago
4 gigs of ram and SQL is on a separate server :/
5 years ago
Seems like that after an application shutdown, the connection to SQL is still active and after the new application start, nopcommerce is not able to connect again, and it will remain like this until an appPool restart
5 years ago
Any update regarding this? Am I the only one who is experiencing this? As far as I see, 4.x is pretty unstable.

Is there any way to log all the errors? Seems like stdout is not logging every errors and exceptions.
5 years ago
I agree that is unstable and nopCommerce team should patch that. Here is fix for your problems with EF:

https://www.nopcommerce.com/boards/t/54986/nopcommerce-410-high-memory-usage-and-how-weve-handled-it.aspx?p=2#215374
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.