I have a microsservice which does search functionality.
In the Data access layer we use Entity framework to speak with DB.
We have millions of records in the DB, for a particular search keyword it takes more time (approx - 110 seconds) since the query takes time to render the data the entity context throws an timed out exception.
The Inner Exception is :
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.",
"ExceptionType": "System.Data.SqlClient.SqlException",
"StackTrace": " at System.Data.SqlClient.SqlCommand.<>c.<executedbdatareaderasync>b__167_0(Task`1 result)\r\n at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()\r\n at System.Threading.Tasks.Task.Execute()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.<executestorecommandsasync>d__c.MoveNext()",
"InnerException": {
"Message": "An error has occurred.",
"ExceptionMessage": "The wait operation timed out",
"ExceptionType": "System.ComponentModel.Win32Exception",
"StackTrace": null
}
So my question is how do i make the code to wait until i get a response from DB.
Is there any web configuration i can add such that i can make the code to wait?
Any suggestions/solutions is highly appreciated.
What I have tried:
I have tried setting the Connection Timeout paramter in connection string to 3000 seconds.
Connection Timeout=120;