How to get the host name and ip

I’ve done some searching, gone through the docs and played around and it’s not obvious to me so I thought I would quickly ask in case somebody knows.

How do I get the host name and IP of the host server of Wowza through server side code? I want to get these values on the application start (onAppStart)

Thanks

Graeme

You could set them in Application.xml Property settings. I don’t think Wowza has a way of knowing what hostname a server is reachable through, or the IP addresses, unless they are set in a VHost /HostPort /IpAddress, in which case there is probably some way.

Richard

From the vhost interface you can get the list of HostPorts:

HostPortList hostPortList = appInstance.getVHost().getHostPortsList();

Charlie

Yes, setting a Property in a VHost.xml or Server.xml will work to avoid maintaining per app

Richard

You can use a hostname in HostPort /IpAddress, and you can get all HostPorts in Charlie’s example, then you should be able to look at each HostPort IpAddress. If it is set using a hostname you can get that.

HostPortList hostPortList = appInstance.getVHost().getHostPortsList();
for (int i=0;i<hostPortList.size();i++)
{
	HostPort port =hostPortList.get(i);
	String ip = port.getAddressStr();
}		

I think this means you have the default “" in the HostPort IpAddress fields, i.e., any IP address. The suggestion is to replace the "” with a hostname (that resolves to a ip on that machine), then it should show up.

Richard

I was wondering if I would need to do that. That sucks, I would have rather it be dynamic so that I don’t have to make a custom Application.xml file for every server we have.

Yes, I realize I can do that, but I didn’t want to. It would be awesome if I could just get it dynamically.

Feature request!! :slight_smile:

Thanks Richard. When I output it I get:

INFO server comment - ip: + [any]

INFO server comment - ip: + [any]

Getting there. I think for now I’ll stick it in the vhost xml file. It’s not too bad of a solution.

Couldn’t you just define those values as properties in Vhost.xml, and then read them using application.getVhost.getProperties() ?