locked
"Bad Gateway" exception when using long url's RRS feed

  • Question

  • I got a REST service created using the WCF Data Service. The service is exposing a context created using Enity Framework.
    1. Everything works calling the service locally.
    2. All GET operations works calling the service through DNS Uri (which is 15 chars longer than "localhost")
    3. Almost all POST operations works while calling the service through DNS Uri
    4. It’s always the same entities that works or fails
    5. When it fails I get a “Bad Gateway” exception, nothing more…L
    ExceptionType: DataServiceRequestException
    Staus Code: 502
    Message:<Error><Code>502</Code><Detail>Bad Gateway.TrackingId:16449c2e-f97f-4eeb-9f3c-c1bcadd85b1f_2,TimeStamp:9/24/2011 5:44:16 PM</Detail></Error>
    By exposing the service using Azure AppFabric Service Bus, which gives a much longer URI, it still works for some entities but fails for even more.
    I have tried setting the maxUrlLength and maxQueryStringLength but with the same result:
    <httpRuntime maxUrlLength="80000" maxQueryStringLength="80000" relaxedUrlToFileSystemMapping="true" maxRequestLength="800000" />
    
    Any ideas?

    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael
    Thursday, September 29, 2011 8:01 PM

All replies

  • Hi Mikael,

    Welcome!

    We will do some more pending research  about your problem and come back as soon as possible, Thanks for understanding.
    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, September 30, 2011 9:14 AM
    Moderator
  • Hi Mikael,

    502 Bad Gateway error is due to the gateway server received an invalid response from an upstream server it accessed to fulfill the request. Do you get any 414 error since it is about the error of requesting URL length exceeds the capacity limit for this server?

    Did your application work earlier?

    Since the 502 Bad Gateway errors may have many possible causes and the gateway may conceal the real error information, could you please try to expose your application from gateway and try to connect to service directly to see if the issue still exists and the error is the same?

    If the issue disappears, please check your network setting and contact with local network engineer.

    If the issue still exists, could you post detailed information here about your error message and the specific failed POST operations?  

    Also, you can follow the steps in Troubleshooting Connectivity Issues in the Windows Azure AppFabric Service Bus http://social.technet.microsoft.com/wiki/contents/articles/troubleshooting-connectivity-issues-in-the-windows-azure-appfabric-service-bus.aspx to have a check on connection to AppFabric service bus.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,

    Connie Ma

    Microsoft Online Community Support

    Friday, October 14, 2011 10:23 AM
  • As stated, everything work using local host. Almost everything works using a (longer) dns name. When connecting using a DNS name, it's always the same entities that fails. When I use AppFabric Service Bus (with even a longer url), even more entities fails.

    I only get a 502 Bad Gateway exception.

    //Mikael


    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael
    Monday, October 17, 2011 6:34 AM
  • Hi Mikael,

    Sorry for my later reply.

    You reposted that you almost everything works using a longer URL but it's always the same entities that fail. As I know that the HTTP specification doesn’t really set a size for the length of a URL, but it does recommend being cautious when going above 255. As your description, it seems that your URL is not so long and the error is not related with “413 (Entity Too Large)” error or “414 (Request-URI Too Long)”. We suspend that the root cause may related with your network setting. For example, there may be URL length setting in your proxy.

    We strongly recommend capturing the Network Monitor trace then you can investigate it and do further debugging. Microsoft Network Monitor download link: http://www.microsoft.com/download/en/details.aspx?id=4865.

    Some information about Network Monitor: http://support.microsoft.com/kb/933741.  


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,

    Connie Ma

    Microsoft Online Community Support

    Tuesday, October 25, 2011 8:59 AM
  • I didn't see this problem until I was exposing my endpoints using Azure Service Bus, which makes up a very long url: https://namespace.sericebus.windows.net/entityRoot.

    When calling the service through the SB I got the same behavor. I did check if I got any calls back to my service but there were nothing in the IIS log. Although, I'm not ruling out the possibility of it being a proxy problem, I find it unlikly.

    I'm currently setting up a new environment on a new network, to see if the problems remain.

    Stay tuned


    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael
    Tuesday, October 25, 2011 9:08 AM
  • Hi Mikeal,

    Thanks for your quick reply.

    You can post here if you encounter the same issue in the new enviroment on a new network, we will gladly help you on it.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,

    Connie Ma

    Microsoft Online Community Support

    Wednesday, October 26, 2011 3:41 AM
  • Hi Mikael,

    Did you happen to find a resolution to this problem?  I've seen a similar error when using the service bus endpoint to relay calls to a backend asmx service.

    Thanks,


    Harin
    Thursday, November 3, 2011 8:33 PM
  • Hi Harim,

    No I haven't as I'm still waiting for a new environment :(


    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael
    Thursday, November 3, 2011 8:37 PM