Layer7 API Management

  • 1.  Handling Connection Reset

    Posted Apr 20, 2017 01:56 PM

    Hello,

     

    Quick question... I'd like to pass back a 502 in cases where the gateway cannot route to a backend service.  For example, if the backend is down, I want the policy to return 502 vs. a 500 error.  I had policy in place for this, but it doesn't seem to kick in as i expect.  I always get back a "Policy Falsified" exception on the routing assertion.

     

    How can I trap this and handle it properly?  Here is a snippet of my routing:

     

     

    Thanks,

     

    Alejandro



  • 2.  Re: Handling Connection Reset

    Posted Apr 21, 2017 04:59 AM

    Hello Alejandro

     

    Thank you for your enquiry.  The Policy snippet looks good, is there any clue in the audit logs as to what is failing on the routing assertion?

     

    Have you ran the policy through the service debugger to understand the flow?

     

    Regards

    Christopher Clark
    CA APIM Support



  • 3.  Re: Handling Connection Reset

    Broadcom Employee
    Posted Apr 21, 2017 05:22 AM

    Hello Alejandro,

     

    Instead of setting the error values , perhaps it would be easier to use the "Customize Error Response" Assertion to return the 502 and Bad Gateway text.

     

    Thanks & Regards,

    Clive



  • 4.  Re: Handling Connection Reset

    Posted Apr 21, 2017 11:41 AM

    I think the problem here is that your Route assertion is within an "All assertions must evaluate to true" assertion. Once the route fails, the "All.." assertion fails, and your policy as a whole fails. Maybe try something like this

    When I put an invalid URL in the Route assertion I get back the customized error response. With this policy logic, either the Route assertion is successful, or the Customize and Stop assertions within the "All..." assertion are executed. I suggest you put the audit assertion outside of(before) the "At least one..." assertion.



  • 5.  Re: Handling Connection Reset

    Broadcom Employee
    Posted May 02, 2017 12:25 AM

    Hello acalbazana ,

    The structure is fine, but the Stop Processing assertion will fail the policy. 

    The stop processing assertion or raise error assertion are usually used to raise the error again, to trigger the Customize error response assertion. 

    ie. if you don't use customize error response, you need to use Return template assertion instead of the Stop Processing assertion to return http code 502 and custom error message.

     

    Regards,

    Mark



  • 6.  Re: Handling Connection Reset

    Posted May 03, 2017 10:10 AM

    Thanks.  Got his covered.  Bill's recommendation was on point.  The "All.." assertion allowed the route assertion to short-circuit my error handling.

     

    Al