I have an ASP.NET application running on IIS 8.5 that times out at 60 seconds regardless of what I set. In other words, I can set the connection timeout to 300 seconds or 30 seconds and the page will still time out at 60 seconds. The Request status code is 504 GATEWAY_TIMEOUT.
Site:
Connection timeout = 300 seconds (5 mins)
Session timeout = 20 minutes
Script timeout = 10 minutes
App Pool:
.NET CLR v4.0
Integrated pipeline
64-bit (32-bit not allowed)
Idle timeout = 20 mins (default)
Other things I've done:
Read just about every article I can on this subject
Set the executionTimeout in my web.config
Restarted the site or ran iisreset after each change
Disabled all sites except this one to isolate it
Created a simple ASPX page in which I set a Sleep thread to under or over 60 seconds, and tried every combination with the connection timeout value.
I'm at a loss. Any ideas?
The answer turned out to be a load balancer, which I was unaware existed, that had its own timeout setting.
Check your maxRequestLength, apparently that can cause a 504 if the incoming request exceeds the default limit of 4MB.
504 Error On Server
Can big ViewState content result a HTTP Error 504 - Gateway timeout?
Related
I have a WCF service and client using reliable session.
Inactivity timeout is set to 1 minute during creation of the service but I need to change this timeout dynamically during runtime to, say, 10 minutes for some time and then set back to 1 minute.
I have tried changing timeout interval before creating of service.
This works of course, although I am not able to change it during runtime.
I also tried to increase another timeouts like Send, Receive and Operation at the same time but it didn't help.
So the question is - is it even possible to change inactivity timeout during runtime or not? If so, should I change any other timeout to make it work?
I changed the timeout in one of my contract implementation methods like this.
Although the timeout is correctly set to 10 minutes, it still behaves like it did with the default timeout.
var binding = OperationContext.Current.Host.Description.Endpoints.First().Binding as CustomBinding;
binding.Elements.Find<ReliableSessionBindingElement>().InactivityTimeout = TimeSpan.FromMinutes(10);
OperationContext.Current.Host.Description.Endpoints.ToList().First().Binding = binding;
We are doing http calls with Windows Authentication between asp.net apps (specifically a .net core an and a standard .net framework 4.5.1 app) apps using System.Net.Http.HttpClient like this:
var client = new HttpClient(new HttpClientHandler { Credentials = CredentialCache.DefaultCredentials });
var response= await _winHttpClient.GetAsync(url);
...
This works fine, except for that the first request takes 10 seconds. The requests then go fast for about 40 seconds, and then one request takes 10 seconds. This cycle goes on forever.
Looking at the IIS logs on the receiving end, we can se that every request is denied (401) and then a follow up request goes through, and every so often the delay between these are about 10s. This is all invisible to the client code - it is worked out by the underlying framework.
Example:
2017-03-17 14:19:40 10.241.108.23 GET /person/search/john - 80 - 10.211.37.246 - 401 2 5 31
2017-03-17 14:19:40 10.241.108.23 GET /person/search/john - 80 utv\frank 10.211.37.246 - 200 0 0 93
2017-03-17 14:19:41 10.241.108.23 GET /person/search/johnn - 80 - 10.211.37.246 - 401 2 5 46
2017-03-17 14:19:51 10.241.108.23 GET /person/search/johnn - 80 utv\frank 10.211.37.246 - 200 0 0 281
It seems as if the credentials are somehow cached, and have to be refreshed every 40ish seconds.
It is worth noting that this problem doesn't occur when both applications are run locally, only when they are run in the actual hosting environment.
What's going on?
Is it expected behaviour that the consumer has to do two calls for every request? And why do some of the requests take 10 seconds to authenticate?
Any help would be appreciated.
If the default is 110 seconds why do I see requests going beyond that (up to 177 seconds)?
I'd expect and hope that once time is reached the request is cancelled and resources reallocated.
I'm seeing these response times in my apm tool (dynatrace) which instruments the code and doesn't likely get the time from the server logs
( referring to In our IIS logs, why do requests last 5 min and longer when executionTimeout is 110 seconds?)
Thank you
Have you considered the requests may be being queued on the server? If you look at perfmon RequestsQueued you might see some queuing going on.
Also look at request wait time to get an indication of how long the last request waited.
Can you send a screenshot of the PurePath showing the Exec Time but also the Elapsed Time column in the tree? Maybe the PurePath itself actually gets aborted by IIS after 110 s but some asynchronous activity in your ASP.NET App is still working and was not interrupted by the IIS Timeout. The PurePath tree should show that as it shows asynchronous subpaths
andi
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.
Turns out there was another timeout setting I wasn't thinking about. Because I host the API and database servers on Amazon Web Services using Elastic Beanstalk, there was a Load Balancer between my desktop application and the API server. The default timeout is 60 seconds. Here is a link to increase the Load Balancer's timeout settings:
http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/config-idle-timeout.html
So here I am, trying to debug a little problem in my ASP.NET web service on localhost, and while I am stepping through it, the darned thing times out. Here I thought the default timeout value was 20 minutes. But the timeout appears to happen at 30 seconds -- I've timed it twice -- although it was 20 seconds in another timing I did.
I've tried to govern this by setting sessionState timeout to 30, in accordance with what MSDN says about HttpSessionState HERE. With this code:
<sessionState
mode="InProc"
cookieless="true"
timeout="30" />
in .
MSDN says the value of the timeout is supposed to be in minutes ("Gets and sets the amount of time, in minutes..."), but it doesn't really seem to make any difference what it's set to. Machine.config does not specify any value, so it should default to 20 minutes.
I am running in IIS 7.5. I checked the properties of the ASP.NET Session State Mode Settings in IIS, and it is selected as "In process". I don't know how this affects things, if it does.
So this is a mystery to me.
If your client is timing out when calling a web service take a look at-
http://msdn.microsoft.com/en-us/library/system.web.services.protocols.webclientprotocol.timeout.aspx