Is it possible to call a Target Server from a Hosted Target?

I wanted to be able to refer to a named Target Server through Hosted Target node.js application. Because some endpoints are HTTPS, the certificate/keystore are also stored with the existing named Target Servers. Is it possible to achieve this? If so, how can it be done?

I have seen answers about getting the host and other details using MGMT API but I don't think that would help with the certificate/keystore.

0 9 245
9 REPLIES 9

I'm not sure I understand. You want to call a Hosted Target but then have that Hosted Target reach out to some Target Server that is named? If your proxy can get this information and pass it to the Hosted Target in a header, that would be the best way to have the originating proxy pass data to the Hosted Target. Then it can use the data and make the appropriate request.

Yes (since the Target Server has the host URL and Keystore reference with the appropriate certificate), maybe I'm not understanding the use of the Hosted Target. Can the Hosted Target directly communicated with the Target Server?

I was trying to implement a retry logic to one of the existing API proxies. I thought the best way to implement it would be to add node.js into the existing proxy (ProxyA which already calls to the backend service using TargetServer) and have the Hosted Target be a middleman (between proxy call and TS). I hope, I can explain this correctly ...

Currently

ProxyA ( API call -> TS) => response returned

Future

ProxyA (HT makes API call (multiple retries) -> TS ) => response returned

Would this be a correct implementation? From your reply, my undemanding is that the Hosted Target should be it's own entity?

ProxyA -> HT Proxy (applies retry logic) => response returned (back to ProxyA?)

Hosted Targets can do whatever Node.js allows it to do, which is more than what you're wanting. If all your HT needs to implement the new functionality (retry logic) is the necessary host to hit, so long as you can get that information into the HT (a Node.js application), you can use vanilla Node.js or any of the plethora of modules available to solve your needs. If your proxy has access to the information necessary for the HT to make the request, send that data downstream from your proxy to the HT in a header, grab the header in the HT and make the request to the target accordingly.

Hi Jeremy,

Thank you very much for your prompt reply, however I am still having a hard time understand this. I just wanted a clarification.

Let's say I have the following Target Server:

{
 "host": "enterprise.com",
 "isEnabled": true,
 "name": "ESBTarget",
 "port": 8080,
 "sSLInfo": {
 "ciphers": [],
 "clientAuthEnabled": "false",
 "enabled": "true",
 "ignoreValidationErrors": false,
 "keyAlias": "key_alias",
 "keyStore": "keystore_name",
 "protocols": [],
 "trustStore": "truststore_name"
 }
}

If I send the target server information as header (whether it's the "name": "ESBTarget" or "host": "enterprise.com" + endpoint .

1. How does the HT associate the given information with the existing TS?

I don't need to access just the target endpoint, I could hardcode the URL in the YAML file but then I would also have to worry about accessing the SSL certificates.

2. I just want to know if it is possible to to have the HT directly communicate with the Target Sever (ex. ESBTarget). Can this be done?

I believe the target variables for load balancer target connection aren't available as variables so I don't believe this approach would work.

You also shouldn't rely on Management APIs as part of your runtime API

A Hosted Target is a Node.js application, so HT can do anything Node.js can do and reaching out to a Target Service is something it can do.

How can it be done?

If I specify that target server within <HostedTarget> of the target endpoint, would that be able to call the Target Server? Because the trace is still pointing towards localhost.

The Hosted Target tutorial is really good. If that doesn't answer things, then maybe a Node.js tutorial would suffice? Long story short, you write Node.js code that handles requests and does stuff. Exactly how, is up to you.

Jeremy,

I appreciate you being responsive and trying to help me solve this problem, maybe I wasn't able to articulate my questions correctly. As it turns out I'm not able to go with Hosted Target usage at this time because HT uses GAE IPs and these IP ranges are too big to be whitelisted with the vendor. And I thought to avoid this issues the HT could directly communicate with the target servers that are defined already in the platform, which is not the case.

Thank you!