cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to access current URL or server IP in script

Highlighted
Guest

How to access current URL or server IP in script

Hello,

We have three Thingworx servers, For development, testing and production hosted with PTC. We have separate configuration Thing to store server specific properties. I don't want to maintain three different Things. But, instead based on URL/IP I want to load properties from Thing. Is there any way to read current server IP/URL ?

8 REPLIES 8

Re: How to access current URL or server IP in script

Not out of the box, we have a Custom Thing with a shared ThingShape/ThingTemplate in order to configure this kind of properties. The only thing to get your current IP will be to call an external "WhatsMyIP" service.

Re: How to access current URL or server IP in script

Nirav, the CurrentSessionInfo Resource has a service called 'GetCurrentIPAddress' to fetch the IP address.

Re: How to access current URL or server IP in script

Hi Aanjan,

Nirav it's asking for Server IP not User IP, anyway GetCurrentIPAddres ( which it's user IP ) almost never works

Carles.

Re: How to access current URL or server IP in script

Ah my bad, I didn't read right. The GetCurrentIPAddres service will return the user address, not the platform.

You can use location.host in an Expression widget (and evaluate that) to get the current server address. You can bind the output to any service.

Re: How to access current URL or server IP in script

But you can't depend on a user entering on a mashup to get Server configuration...

Re: How to access current URL or server IP in script

Is it possible to write an extension to read server IP and call service from script ? whatismyip is 3rd party, I want to avoid it, if possible.

Re: How to access current URL or server IP in script

I suppose yes, it's just Java, just doing a google search: How to get Server IP address in Java

Re: How to access current URL or server IP in script

True, but this would depend on the use case. If Mashups are ultimately going to be used to pass through, this can be stored in a variable and passed on to a service.