How to programmatically obtain the URL for CSP application on a given server?

Hi, folks!

Suppose I have a CSP app, which provides some service.

And the code of my App knows the name of the CSP App in form: /myappname

How can I programmatically obtain the URL for CSP apps to send the full qualified link to the users(e.g. via email) of my app?

E.g. https://productionserver.com/myappname

 

  • + 1
  • 0
  • 226
  • 4
  • 2

Answers

I was thinking that $SYSTEM.INetInfo.LocalHostName()

might be of help... however, that just gives the local host name, in my case "J2EDDEMOEL".

So, I tried the result of $SYSTEM.INetInfo.HostNameToAddr($SYSTEM.INetInfo.LocalHostName())
but that gives me an address that is valid only within my local area network (in my case 192.168.56.1), whereas one would need 71.174.62.16 to get to my systems from outside of the local area.

 

In other words: if you're only accessing that application from your local area network, the above reference would give you a usable address for the web-reference, but otherwise, I'm not sure how you'd get that programmatically.

 (in my case 192.168.56.1), whereas one would need 71.174.62.16

This means you try to get information that is stored in your router's and/or firewall's  (NAT, DHCP,... ) routing/mapping table.
I'd assume you need to use some utility of your OS using $ZF(-1,...) $ZF(-2,...) to get the outside view of the inside server

This might work inquiring nslookup on a DNS server outside your NAT, ...  Though I never tried it

Such a roundtrip for knowing something that should be configurable.

I don't think you should depend on INetInfo since normally you know where you're hosting your service. Make the address configurable and this will prevent headaches, after that you just need to concatenate with your CSP file address.

 


 

+1 for this. Your app could be under proxy, firewall, load balancer, on a multi-site host, and usually "default" machine name would be some networking guy's favourite cartoon character or not configured at all, rather than your app domain name anyways. 

Just have it as a config option.

Now I will spend half the evening changing hostnames to cartoon characters.

Comments