I'm using Entity Framework 6 to access a SQL Server in an API application. The API server and DB server are separate. I have a known long query that takes a little more than a minute to run. I have set the CommandTimeout on my EF DbContext using the following code:
db.Database.CommandTimeout = 20 * 60; // 20 minutes
Unfortunately, this does not seem to have any affect because the query still times out in less than a minute and the server returns a 504 Gateway Timeout error.
Why does this change not have any affect on the command execution time limit?
Is there something else I should be doing to allow this query to run longer?
Some more details:
I have written a desktop app that makes API calls to an API server which in turn makes queries to the db server. On the desktop application side, I have set the HttpClient property:
httpClient = new HttpClient { Timeout = new TimeSpan( 0, 20, 0 ) };
On the API server side, I have set the execution timeout:
<system.web>
<httpRuntime requestPathInvalidCharacters="" maxRequestLength="2097151" executionTimeout="30000" />
</system.web>
And on the API server, I've set the SQL command timeout as above.
At some point, the response always ends after a little less than a minute despite the fact that I've set all the timeouts I can think of to 20 minutes. I assumed the 504 was caused by the db timeout, but I suppose it's just as likely that it's between the desktop app and the API server.
Regardless, I'm running out of ideas so anything will help.