Asynchronous HTTP Requests in an API proxy to another API proxy

Hello,

I have a requirement to call an API proxy from another API proxy and the call can be Asynchronous. Currently I am trying to achieve this using Jvascript policy using httpClient but getting an error with error text :Timed out. Not sure why.

Just wanted to know if Apigee supports async https call to another proxy and if so is it recommended.

Thanks.

0 10 1,864
10 REPLIES 10

Not applicable

Hello @GargiTalukdar,

Have you referred to the discussion we had here ?

What about a node.js based implementation using the async module. That would perfectly behave in an async way, if coded correctly by adhereing to the node.js call back mechanism.

And this node.js code can then be invoked from a resource based service callout way.

Hi @MEGHDEEP BASU,

I am trying to make the call using JS httpClient method as node is not in the scope currently.

The call works fine when we make an async call to other service but it is failing when I try to make a call to another proxy.

Need some clarification on whether Apigee supports async https call using httpClient in javascript policy to another proxy. If not we will have to look for some other option.

Thanks!!

Also one more query ..Can we invoke node.js using service callout policy?

As we cannot have node in the target since this will not be our primary target.

Yes. From service callout policy call a resource and add the node.js code as the target of that resource.

Thanks for the note..But still we would not prefer to use service callout here as doing so it will add to the response time.

Hi @MEGHDEEP BASU,

I guess the post is about making 3 call and then mashup response from all the 3 calls. Please correct me if I am wrong. But for us the primary target call is not async and also we are not trying to mashup the response.

Our flow will work as follows:

1. call the primary target

2. if success then we do some other manipulation and execute few more policies and then make an async call to the proxy. We do not want to wait for the response from the proxy call and the call to end.

3. if error raise fault and stop the execution.

Hi,

After doing some trial I am assuming that calling a proxy from another proxy using httpClient is not supported as doing so I am always getting timed out error. Please correct me if I am wrong.

Thanks.

> I am assuming that calling a proxy from another proxy using httpClient is not supported as doing so I am always getting timed out error.

I think your assumption is not correct.

A proxy hosted in Edge is just an HTTP endpoint.

Calling a proxy from a JS Callout is perfectly normal.

I think you must be careful to create a thread-starvation issue if you run the system at scale. But that is a matter of scale, not of functional correctness.

You can call any HTTP endpoint using httpClient from within a JS Callout, including an endpoint that happens to be hosted in Edge as a proxy. Be sure to use the correct hostname and scheme.

I suspect your timeout is due to some other problem.

@Dino Thank you so much for the clarification. I checked in the trial org and it seems to be working fine but not sure why it is not working in our on-premise setup.

@GargiTalukdar Did you find a solution to this issue? I am facing the same problem on our on prem solution.