If anyone is interested I found a work around for getting the host name. It is a funky and not ideal work around but it works for us. And if there is another way I am open to it.
We use the os.system to ping the ip address and create a logfile just like you would in command line. When run in a client session the script is run on the server and the logfile saved in reference to the server drives, in the case below the D drive on the server (I created folder just for this on the server). After the command is run it then reads in this file as a string and parses it as the computer name. Obviously you still need a proper working DNS but all the other methods were hit or miss for us and this works most consistently of all methods.
########################
##getHostName gets the computer name from a given ip
##inputs
##ip string - IP address of host to get the name for
##logFolder string - location to store the logfile for use in getting the name
##outputs
##hostName string - name of host if found if not will be ip
#######################
def getHostName(ip,logFolder = 'D:\\HostNameCheck\\'):
#create path for logfile and empty file if it exists
logFile = logFolder + ip + '.log'
system.file.writeFile(logFile,'',0)
#create string for command line to be used, >> preceeds logfile location
cmdString = 'ping -a ' + ip + ' -n 1 >> ' + logFile
import os
pingBad = os.system(cmdString)
hostName = ip
#when pingBad == 1 then the ping failed.
if pingBad == 0:
fileString = system.file.readFileAsString(logFile)
#if ' [' is in the log file then the system found a name if not just the ip
if ' [' in fileString:
#Split the string to get the computer name
#first remove everything after the name, then everything before and then lastly the Domain
hostName = fileString.split(' [')[0].split('Pinging ')[1].split('.')[0]
return hostName
Did you try setting the new option in the gateway to do the name lookup for you? Also, you need to encase your code in three back ticks `
Damn, I was about to edit my post haha
Thank you for the help on the code posting, it was my first post and I clicked on the code icon but I didn't have any text highlighted, so it didn't work.
Also, we do have the box checked to resolve the name. It gets a name sometimes but not always, likely something with our DNS and records not getting updated quickly enough. Pinging the IP works in the moment and consistently.
I have configured a new perspective project. I created a security zone which I assigned to IP address of 127.0.0.1. While I am accessing the project in the design, I am able to determine the IP address of the device accessing the project, but when I run the project in the browser it is not detecting the IP address. Is there a way of finding the IP address when running in the browser?
What is the value of the property session.props.address
in the browser session?
I get the following value of the session.props.address in the browser:
When I view the value in the designer, it's 127.0.0.1 as expected
That's still localhost, but in IPV6, instead of IPV4 (127.0.0.1). Either tell your browser/gateway not to use IPV6, or add it to your security zone.
Doesn't this just means he's running the client from the gw using the loop back address instead of the gw's ip address? That's the only way you could see this address here.
Oh wait, I just reread the OP, nvm
Is this the setting on the Web Server configuration page?
Ok so I disabled the ports on the network adapters and also disabled the rule in firewall to not allow IPv6 connections. When I look at the network stats. It looks like I connect to the browser via IPv4 port 8088:
but I still have the same address in the Ignition:
Interestingly, when I tried to connect to it from another device that is on the local network, it did display the correct address:
I think that I will include the IPv6 in the list of addresses that belong to the zone as suggested.
When I've done this before, I had to restart the client before it let it go (terminating the session didn't work). That, and/or disabling ipv6 on all adaptors.