Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding RRS feed

  • Question

  • User-1651183775 posted

    Hello Guys,

    i am getting error "Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding". I am using WCF data service using Entity Framework 6 to get the data. Can anyone help me with this?

    I have already tried below things:

    1. Context.Timeout=180 while calling service
    2. Execution timeout=100 in SSMS
    3. connect Timeout=120 in connection string

    but none of the above works.

    Error on this link. https://file.io/oUmeEm

    Saturday, December 30, 2017 9:57 AM


All replies

  • User1120430333 posted

    Maybe,  you are getting deadlocks if the tables being used are being used in multi-users environment, and T-SQL NoLock is not being used by any application accessing the tables.


    Saturday, December 30, 2017 1:46 PM
  • User-1651183775 posted

    I feel deadlock is one of the possibility.

    I am using DataServiceContext in my case. I dont get Executestorecommand property for context object. what would be the correct way to set this property?

    var context = newMyEntities(new Uri(constants.ServiceUrl())); context.IgnoreResourceNotFoundException = true; context.IgnoreMissingProperties = true; context.Timeout = 900;

    Sunday, December 31, 2017 10:12 AM
  • User-484054684 posted

    As you are trying to set the timeout dynamically (through code), try removing the value in connection string (config).

    See this discussion: https://stackoverflow.com/a/6234593

    Also remarks section in documentation https://msdn.microsoft.com/en-us/library/system.data.entityclient.entitycommand.commandtimeout%28v=vs.90%29.aspx that says "The EntityCommand instance always sets this value on the underlying data provider before executing the underlying command. A command time out supplied through a connection string or any alternative mechanism other then explicit invocation of the CommandTimeout property is ignored."

    Sunday, December 31, 2017 10:20 AM
  • User-1651183775 posted
    1. i am setting "context.Timeout" property just to let you know what all things i have tried so far. I have not mentioned anything in connection string yet. 
    2. According to stackoverflow discussion many people have accepted it as answer to context.Timeout=180 which in my case is not working 
    Sunday, December 31, 2017 11:05 AM
  • User1120430333 posted


    I suggest that you check for deadlocks. If deadlocks are occurring, then you have to find out what applications are creating the locks and correct those applications.

    Sunday, December 31, 2017 11:07 AM
  • User753101303 posted


    The link you posted seems dead. Posting the whole exception message including the call stack might help to better understand which kind of timeout it is. For now it seems to be a SQL command execution timeout ? (seems you are talking about a DataServiceContext for now ?) Your query is expected to take much time or to return a huge amount of rows?

    Once you know exactly which timeout it is, try to fix the root cause and increase the timeout value only as a last resort. The goal is precisely to avoid running operations that are taking more time than expected (for example it's common even for a web service to return pages or filter data rather than to return a huge payload).

    Sunday, December 31, 2017 1:49 PM
  • User-1651183775 posted

    I am using DataServiceContext to get data from SQL DB using WCF service and StackTrace is as under:

    [DataServiceClientException: <?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code /><m:message xml:lang="en-US">An error occurred while processing this request.</m:message><m:innererror><m:message>An error occurred while executing the command definition. See the inner exception for details.</m:message><m:type>System.Data.Entity.Core.EntityCommandExecutionException</m:type><m:stacktrace>   at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)&#xD;
       at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)&#xD;
       at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClassb.&lt;GetResults&gt;b__a()&#xD;
       at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)&#xD;
       at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;&gt;c__DisplayClassb.&lt;GetResults&gt;b__9()&#xD;
       at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)&#xD;
       at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)&#xD;
       at System.Data.Entity.Core.Objects.ObjectQuery`1.&lt;System.Collections.Generic.IEnumerable&lt;T&gt;.GetEnumerator&gt;b__0()&#xD;
       at System.Lazy`1.CreateValue()&#xD;
       at System.Lazy`1.LazyInitValue()&#xD;
       at System.Lazy`1.get_Value()&#xD;
       at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()&#xD;
       at System.Data.Services.QueryResultInfo.MoveNext()&#xD;
       at System.Data.Services.DataService`1.SerializeResponseBody(RequestDescription description, IDataService dataService, IODataResponseMessage responseMessage)&#xD;
       at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)&#xD;
       at System.Data.Services.DataService`1.HandleRequest()</m:stacktrace><m:internalexception><m:message>Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.</m:message><m:type>System.Data.SqlClient.SqlException</m:type><m:stacktrace>   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)&#xD;
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)&#xD;
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)&#xD;
       at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)&#xD;
       at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()&#xD;
       at System.Data.SqlClient.SqlDataReader.get_MetaData()&#xD;
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)&#xD;
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task&amp; task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)&#xD;
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task&amp; task, Boolean&amp; usedCache, Boolean asyncWrite, Boolean inRetry)&#xD;
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)&#xD;
       at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)&#xD;
       at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)&#xD;
       at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)&#xD;
       at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.&lt;&gt;c__DisplayClassb.&lt;Reader&gt;b__8()&#xD;
       at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TInterceptionContext,TResult](Func`1 operation, TInterceptionContext interceptionContext, Action`1 executing, Action`1 executed)&#xD;
       at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)&#xD;
       at System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)&#xD;
       at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)&#xD;
       at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)</m:stacktrace><m:internalexception><m:message>The wait operation timed out</m:message><m:type>System.ComponentModel.Win32Exception</m:type><m:stacktrace></m:stacktrace></m:internalexception></m:internalexception></m:innererror></m:error>]
       System.Data.Services.Client.QueryResult.ExecuteQuery() +253
       System.Data.Services.Client.DataServiceRequest.Execute(DataServiceContext context, QueryComponents queryComponents) +273
    Sunday, December 31, 2017 6:08 PM
  • User1120430333 posted

    I am using DataServiceContext to get data from SQL DB using WCF service and StackTrace is as under:

    It looks to me that WCF is timing out before the operation can be completed, which you should be able to adjust I would think. Maybe, you should consider posting to a WCF forum.

    Sunday, December 31, 2017 8:32 PM
  • User1120430333 posted


    You may want to use it. You can use Bing or Google to find examples.

    Monday, January 1, 2018 4:48 PM
  • User1168443798 posted


    This issue has been resolved at thread below in MSDN:

    #Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding

    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 3, 2018 6:34 AM