How to access current URL or server IP in script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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 ?
- Labels:
-
Install-Upgrade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Nirav, the CurrentSessionInfo Resource has a service called 'GetCurrentIPAddress' to fetch the IP address.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Aanjan,
Nirav it's asking for Server IP not User IP, anyway GetCurrentIPAddres ( which it's user IP ) almost never works
Carles.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
But you can't depend on a user entering on a mashup to get Server configuration...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I suppose yes, it's just Java, just doing a google search: How to get Server IP address in Java
