Client Network IP Tag shows loopback 127.0.1.1 instead of IP

I’ve hit a bump… I want the client’s IP … And the tag shows a loopback address…

Anyone have a trick to get my Client IP address ???

Is the gateway service running on the same machine? If so, and you launched from localhost, the client IP really is from localhost. Ignition wouldn’t know what other IP address applies since it isn’t using it at that point.

Or did you launch across a network and the client IP is still localhost?

No it’s not the Gateway… it’s a remote pc that the client is running on.

If you must have the client IP addresses without regard to the actual path the server, you can script it like so:from java.net import NetworkInterface interfaces = NetworkInterface.getNetworkInterfaces() for iface in interfaces: print iface addresses = iface.getInterfaceAddresses() for addr in addresses: print addr.getAddress()

Odd. I suspect you are running some form of antivirus that is diverting your connections through a local proxy. Try the script function system.net.getExternalIpAddress().

No AV or Proxy. It’s a linux box… Ubuntu 14.04 with Oracle Java 7 (Never use Java 8 with Ubuntu btw… the screen freezes in clients and as a Designer you can’t select the projet you want to work on)

So yeah the output of that is :

name:wlan0 (wlan0)
/IPv6 Address(Not gonna type that)
/10.0.5.178
name:lo (lo)
/0:0:0:0:0:0:01%1
/127.0.0.1

So if I want just to return the 10.0.5.178 I’m having an issue, because if I try addresses = interface[0].getInterfaceAddresses()
instead of going thru the loop and then addresses[1].getAddress() it doesn’t work

Guess you can play into that like in datasets ??

Event with the name ‘wlan0’ it won’t work…

[quote=“EricFrancoeur”]No AV or Proxy. It’s a linux box… Ubuntu 14.04 with Oracle Java 7 (Never use Java 8 with Ubuntu btw… the screen freezes in clients and as a Designer you can’t select the projet you want to work on)
[/quote]

I think this is a bug with Java webstart - if you use the native launchers to run the client and designer you should be able to use Java 8 without issue.

[quote=“Kevin.Herron”]
I think this is a bug with Java webstart - if you use the native launchers to run the client and designer you should be able to use Java 8 without issue.[/quote]

I should test that someday…

Thanks to pturmel, I was able to play with the java class he showed me and create the function I need!!

project.Terminal.getIPAddress('wlan0')

def getIPAddress(PortName, IPV6=None):

	if IPV6 is None:
		intIPVersion = 1
	else:
		intIPVersion = 0
	
	from java.net import NetworkInterface
	interface = NetworkInterface.getByName(PortName)
   	addresses = interface.getInterfaceAddresses()
   	
   	dtaIPs = []
   	for addr in addresses:
   		dtaIPs.append((str(addr.getAddress())).strip('/'))
   		
   	return dtaIPs[intIPVersion]

This is definitely a bug/undesirable consequence. Running a project on a Raspberry Pi has the same effect, it pulls the loopback instead of eth0, on a windows PC the tag is fine through. In my mind it would be better if it was at least an array that you could go through.

When using a combination of pi / windows it gives a headache as some work some don’t. I made the following code to overcome this when getting the MAC at least. Hopefully it helps someone.


mac = getMacPiSafe()	

def getMACAddress(PortName, IPV6=None):
   	    
   	    	if IPV6 is None:
   	    		intIPVersion = 1
   	    	else:
   	    		intIPVersion = 0
   	    	
   	    	from java.net import NetworkInterface
   	    	interface = NetworkInterface.getByName(PortName)
   	       	addresses = interface.getInterfaceAddresses()
   	       	
   	       	dtaIPs = []
   	       	for addr in addresses:
				ip = addr.getAddress()
				network = NetworkInterface.getByInetAddress(ip)
				mac = network.getHardwareAddress()
				strmac = ':'.join('%02x' % (b) for b in mac) 
				   	       	
   	       	
   	       	if len(dtaIPs)>0:
   	       		return dtaIPs[intIPVersion]
   	       	else: 
   	       	    return None

def getMacPiSafe():
	mac = system.tag.read('[System]Client/Network/MACAddress').value
	eth0mac = getMACAddress('eth0');
           
	if(mac==None): 
	   return (eth0mac)
	else:
	   return (mac)