Email notifications error "System.Data.SqlClient.SqlException: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding"

In some scenarios when you set up email notifications (On Premise or Azure scenario) ,you might get the following error in the log of email notifications. The error occurs because Email Notifications mechanism has too many notifications to serve and isn't capable of processing them, according to Timeouts on SQL.


2017-11-27 13:27:02,245 KanBo.EmailNotifications.InstanceNotificationMessagesRouter DEBUG | Obtaining notifications to send
2017-11-27 13:27:35,093 KanBo.EmailNotifications.InstanceNotificationMessagesRouter ERROR | An unexpected error occured while routing notifications from instance 1
System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out
   --- End of inner exception stack trace ---
   at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__174_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<ExecuteStoreCommandsAsync>d__c.MoveNext()
   --- End of inner exception stack trace ---


Please open the SQL Server Management Studio and select KanBo Content Database. Click with right cursor on it and select New Query.





Now enter the following query:


UPDATE nu
SET nu.wasMailed = 1
FROM
    NotificationUsers nu
    JOIN Notifications n
        ON nu.NotificationId = n.Id
   WHERE CreationDate <; '2017-11-01'

A date 2017-11-01 can be changed. Please select a date to suit the time from which you would like to get previous email notifications. In case you have many notifications, we recommend to choose a recent date, i.e. last month.


Now execute the query. Your Email Notifications should start working now.


Email notifications

This article was helpful for 1 person. Is this article helpful for you?