System.net functions are not working

Hi All,

I am trying to troubleshoot a script on a tag that uses the system.net functions. Essentially, we are trying to store some gateway information in some custom tags, which are later on used on some more elaborate navigation scripting across all ignition gateways in our campus.

We created a tag that stores the gateway IP address and hostname among other info, and we have a script that uses the system.net.getIpAddress() and system.net.getHostName() functions to pull this data into the tag, but the data being returned from both functions is null.

I even tried creating individual tags that run nothing but these system scripts, but I am still only receiving null data into those tags. Has anyone run into a similar issue?

We are running perspective on ignition 8.1.35.

Thanks in advance.

Where is the script running? you need to make sure that you are running in gateway.

I was able to get both commands to successfully return the hostname and IP by creating a gateway event message handler with this script

def handleMessage(payload):
	return (system.net.getHostName(), system.net.getIpAddress())

and then called it with system.util.sendRequest(). system.util.sendRequest | Ignition User Manual

Thanks for your reply, looks like it was a problem caused by our domain controller being down. Not too sure how the issues were related, but the functions now work as expected!

Ignition has to use a reverse DNS request to convert an IP address to a hostname.

It's always DNS

Fair enough, I get not being able to resolve the hostname, but shouldn't it still be able to return the host IP?

If there's only one, I think. Keep in mind that the function looks at the gateway's IP address when running in a Perspective script. For Perspective, you should be using session.props.host value.