Can we set conditional api timeouts?

Not applicable

Hi,

We would like to return a timeout error if the proxy takes longer than we want. So for this, we have set the api.timeout as a property in <HTTPProxyConnection>. See below...

    <HTTPProxyConnection>
        <BasePath>/v1/blah</BasePath>
        <Properties>
            <Property name="api.timeout">500</Property>
        </Properties>
        <VirtualHost>default</VirtualHost>
        <VirtualHost>secure</VirtualHost>
    </HTTPProxyConnection>

This works fine. When the request takes longer than 500ms, then a 504 error is returned.

However, one of the conditional flows within the proxy endpoint takes a bit longer than the other flows. Rather than increase the timeout value to cater for the longer time, is there a way to set different timeouts? I would like to keep this conditional flow in this proxy endpoint if possible.

Solved Solved
2 2 753
1 ACCEPTED SOLUTION

Nope, I think you cannot use a variable there.

But you have options.

  1. specify a separate ProxyEndpoint, with... basically has the same configuration, but a different basepath, and a different timeout.

        <HTTPProxyConnection>
            <BasePath>/v1/blah/foo</BasePath>
            <Properties>
                <Property name="api.timeout">1500</Property>
            </Properties>
            <VirtualHost>default</VirtualHost>
            <VirtualHost>secure</VirtualHost>
        </HTTPProxyConnection>
    

    This will work if you can distinguish the "slow" flow from the "non-slow" flows by basepath.

    You can include this proxyendpoint into the same proxy bundle as the original proxyendpoint, and Apigee Edge will do the right things with regard to routing of inbound requests.

  2. set the timeouts on the other end - on the TargetEndpoint. Use distinct TargetEndpoints for the slow vs the non-slow requests, and use RouteRules within the ProxyEndpoint to route inbound requests to the different TargetEndpoints. Backoff the proxy timeout to be 10000, but use 500 and 1500 on the timeout for the Target. This would use just one ProxyEndpoint.

View solution in original post

2 REPLIES 2

Nope, I think you cannot use a variable there.

But you have options.

  1. specify a separate ProxyEndpoint, with... basically has the same configuration, but a different basepath, and a different timeout.

        <HTTPProxyConnection>
            <BasePath>/v1/blah/foo</BasePath>
            <Properties>
                <Property name="api.timeout">1500</Property>
            </Properties>
            <VirtualHost>default</VirtualHost>
            <VirtualHost>secure</VirtualHost>
        </HTTPProxyConnection>
    

    This will work if you can distinguish the "slow" flow from the "non-slow" flows by basepath.

    You can include this proxyendpoint into the same proxy bundle as the original proxyendpoint, and Apigee Edge will do the right things with regard to routing of inbound requests.

  2. set the timeouts on the other end - on the TargetEndpoint. Use distinct TargetEndpoints for the slow vs the non-slow requests, and use RouteRules within the ProxyEndpoint to route inbound requests to the different TargetEndpoints. Backoff the proxy timeout to be 10000, but use 500 and 1500 on the timeout for the Target. This would use just one ProxyEndpoint.

Oh thanks for your response. It would be nice if it accepted a variable!

Unfortunately, I had already looked at these 2 options and they won't work for us. We need them to have the same basepath. Also, there is no target endpoint for this scenario.

Thanks anyway!