Amazon Ad

Wednesday 19 June 2013

504 Gateway Time-out - The web server is not responding, ASP.NET WCF Service.

Hi Folks,

I was facing a problem in my phonegap android mobile app with ASP.NET WCF REST Service, The error used to say 504 Gateway Time-out - The web server is not responding.

But the app was working on many devices but was giving this error on some devices including Samsung S3 I747.

My first impression was the problem is with the web server. I checked the performance which was ok and also checked the code which was .net wcf with LINQ which was also giving result on a decent speed and time.

I also restarted my IIS to clear the cache but still no affect the same error was produced again on the same device.

The first step i took was to enable error tracing in IIS, Which is available in IIS under name "Failed Request Tracing Rules". I activated this with error codes 400,402,500,504 to find out what causes this problem.

When i checked the log files it showed me the error code which was 402 when tried to connect with samsung s3 phone. Here is how i sorted out the problem in three easy steps.


Step 1: Since this error is a status code in a browser my first doubt was that the browser might not be supporting some configuration. So i added the below line in my web.config file

<system.web>
    <browserCaps userAgentCacheKeyLength="256" />

Step 2: Since my WCF service was expecting to give the result in a big time so i decided to increase my response time, close time,receive time, open time and close time. So i added the following line in my web.config file

<bindings>
      <webHttpBinding>
        <binding closeTimeout="10:01:00" openTimeout="10:01:00" receiveTimeout="10:01:00" sendTimeout="10:01:00" maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000" useDefaultWebProxy="true" allowCookies="false" crossDomainScriptAccessEnabled="true" name="cabservicebinding">
          <security mode="None"></security>
        </binding>
      </webHttpBinding>
    </bindings>

Step 3: To activate caching in my WCF results, I also decided to add the following line in web.config in system.servicemodel tag

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

After this, I restarted my IIS and the things started to work fine. Hope this helps to you all.

Thanks
Ritesh Tandon

1 comment:

Esakki said...

thanks , will try to follow the same steps

Post a Comment

Comments are welcome, Please join me on my Linked In account

http://in.linkedin.com/pub/ritesh-tandon/21/644/33b

How to implement Captcha v3 in ASP.NET

 I was facing an issue of dom parsing in my website. I finally resolved it by using Google Captcha V3. Step 1: Get your keys from https:...