locked
How to resolve error - 502 web server error ? RRS feed

  • Question

  • Hello,

    Kindly consider following scenario: 

    Custom control is programmatically creating site using following code. Once site get created, it redirecting to its settings.aspx page:

    try

                {

                    SPSecurity.RunWithElevatedPrivileges(delegate()

                 {

                     using (SPSite site1 = new SPSite(SPContext.Current.Site.ID))

                     {

                         SPLongOperation.BeginOperation beginOperation = null;

                         if (beginOperation == null)

                         {

                             beginOperation = delegate(SPLongOperation longOperation)

                             {

                                 site1.WebApplication.Sites.Add(site1.RootWeb.Url                    + "/manPath/site1, Site1, "", 1033,TemplateName, __userLoginName, __userName,__userEmail);

                                 

                                 longOperation.End(site1.RootWeb.Url + "/manPath/site1/_layouts/settings.aspx");

                             };

                         }

                         SPLongOperation.Begin(beginOperation);

                     }

                 });

                }

    Same code works perfect at development machine, while in production it gives 502 web server errors.

    Please check below error text:

    502 - Web server received an invalid response while acting as a gateway or proxy server.

     

    There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.

    Results in Development machine: site gets created and redirects to its site settings page as expected.

    Results in Production machine: During the process it throws 502 web server errors, while site has got created successfully.

    I am not sure why it happened, while previously it was working. I have feeling that may be redeployment should resolve the issue, but I want to know root cause of this issue!!

    Note :  the same settings page is working well, when I open it manually in production environment!

    Please let me know the approaches to resolve this issue? Also, let me know if you need any further information on same.

    Thank you to look at this issue !

    Kind Regards,


    Dipti Chhatrapati

    Wednesday, April 2, 2014 10:35 AM

Answers

All replies

  • Hi Dipti,

    The 502 shows an issue with the page you are looking for, and it cannot be displayed. When the web server contacted the upstream content server, it received an invalid response from the content server.

    It seems the ARR proxy was timing out before back application server could respond, the default time-out value for ARR proxy is 30 sec. increase the ARR proxy time-out value in IIS to 60 sec to accommodate requests that take more than 30 seconds to respond.

    Thanks,


    Qiao Wei
    TechNet Community Support

    • Proposed as answer by SekThang Thursday, April 3, 2014 8:32 AM
    • Marked as answer by Qiao Wei Monday, April 14, 2014 10:07 AM
    Thursday, April 3, 2014 8:15 AM
  • Hi Qiao,

    Thank you to look at this thread, yes its due to invalid response - however solution for this is not yet working !

    I have changed idle time of respective application as 1 minute as shown in below image :

    above settings has not resolved 502 web server error , would you please let me know where I may be wrong ?

    Thanks and Regards,



    Dipti Chhatrapati

    Thursday, April 3, 2014 9:25 AM
  • Hi, I have found the things where is the issue , but still I am looking for the resolution !

    To add further on above issue, I have observed as below :

        Client machine: Following error is getting throw when creating new  site. 

    502 - Web server received an invalid response while acting as a gateway or proxy server. 

    There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server. 

    WFEs machine : Error is not getting display when creating new site.

    And hence , it looks like load balancing/IIS issue, however I am not sure how to resolve the same !! 

    Please let me know your thoughts !

    Thanks and Kind Regards,


    Dipti Chhatrapati



    Friday, April 4, 2014 8:07 AM
  • Can you please take a filler trace\Httpwatch trace and send it. I assume I know the issue but let me know with network traces.

    BTW the issue is not related to SharePoint so the SharePoint setting which you have set would not be of any help.

    Changes need to be done on Load Balancer.

    Also please share below along with traces:

    1. What load balancer is used.(Hardware\software and company etc)

    2. Build of SharePoint installed.

    3. No of windows server and there service pack with built details.

    I have seen this issue on Windows server 2008 sp1

    Friday, April 4, 2014 8:57 AM
  • Hi Inderjeet,

    Thank you very much to look at this issue !

    I do not have idea about trace\Httpwatch - can you please explain bit further how to trace ?

    Kindly consider the below requested details:

    1. What load balancer is used.(Hardware\software and company etc)

    Its Hardware Load balancer . I do not have much idea further on this

    2. Build of SharePoint installed.

    Its SharePoint Server 2010 standard version - 14.0.6029.1000

    3. No of windows server and there service pack with built details.

    Its 2 WFEs having Windows Server 2008 R2 standard SP1

    Kindly let me know your ideas on same further.Thanks once again !

    Best Regards,


    Dipti Chhatrapati

    Friday, April 4, 2014 3:14 PM
  • Hello,

    Finally root cause of this issue has been found !

    Its has happened because ARR proxy configuration for the load balancer has a timeout of 30s.

    Increasing the timeout as 120s has fixed the issue.

    Kindly check the below reference links :

    http://blogs.iis.net/richma/archive/2010/07/03/502-3-bad-gateway-the-operation-timed-out-with-iis-application-request-routing-arr.aspx

    http://www.iis.net/learn/extensions/troubleshooting-application-request-routing/troubleshooting-502-errors-in-arr

    Hope its helpful to others.

    Thanks and Kind Regards,


    Dipti Chhatrapati

    • Marked as answer by Qiao Wei Monday, April 14, 2014 10:07 AM
    Thursday, April 10, 2014 9:22 AM