How to get the host name and port of current IS Server?

Hi,

Is there a public function/service to retrieve current Integration Server’s host name and port?

I do an experiment by creating a service called “getHostname” that called this undocumented hidden service: “wm.server.query:getSystemInfoAsIData”, but I got this error when the service run:


Could not run ‘getHostname’.

com.wm.lang.flow.FlowException: [ISC.0049.9010] Service ‘com.axis.util.server:getHostname’ invoking unknown service ‘wm.server.query:getSystemInfoAsIData’ at ‘Invoke for wm.server.query:getSystemInfoAsIData’. The service may have been renamed, moved or disabled.

What is the cause of this?
Is there any alternative way to get the server’s host name and port?

From the Java API:

ServerAPI.getServerName() returns the host name of the server.

ServerAPI.getCurrentPort() returns the port. Be advised that this will return -1 when the session is run from the scheduler, file polling port, etc.

1 Like

wm.server.admin:getServerHost will give you host name and the admin port of the server. The default ACLs on this service prevent it to get listed in the “Find” etc options. However you can invoke it and verify the results.

Be advised that this service is not public and not intended for our use. Future versions may not support this service (though it seems unlikely to go away).

The ServerAPI methods are documented and are intended for our use.

Then how to get current server port if service is run from scheduler, etc ?

There is a difference, when I tried, ServerAPI.getServerName() returns IP address (ie: 10.20.10.66) instead of host name (ie: my-server).

Back then, I tried this java code to get current host name:

        IDataCursor cursor = pipeline.getCursor();
        try {
            java.net.InetAddress addr = java.net.InetAddress.getLocalHost();
            String hostname = addr.getHostName();
            IDataUtil.put(cursor, "hostname", hostname);
            
        } catch (java.net.UnknownHostException e) {
            throw new ServiceException(e.toString());
        }

It returns host name (not IP address) like wm.server.query:getSystemInfoAsIData.

Is it okay with this way?

Then to get current server’s port, I tried with this public service: pub.utils:getServerProperty with property name watt.server.port. Is using this service, can we get current server port even when run in scheduler?

In this case, there is no port involved so no port is returned.

Yes.

That isn’t the “current” port but is the primary listening port that is configured for the server. That can be useful for emails/logging to identify the IS instance but doesn’t indicate which port, if any, was used for the current thread execution.

I am a bit confused about this, isn’t all of services in IS are resided and executed in IS server which the port is the port defined in watt.server.port ?

What kind of scenario that a service in IS can be run with different port besides of port defined in watt.server.port ?

Please enlighten me.

When a service is executed by the scheduler or via triggers or notifications there is no communication port involved. Only when services are invoked via HTTP or FTP mechanisms will a port be used.

The primary port that is configured tells IS on which port to listen for HTTP calls. When a service is invoked by other means that port is not used.

Hi All,

Could you please help me here to find out java version in flow service?

Thank You

Hariom

Hi Hariom,

might have been better to open a new thread for your question

You can try to get the java version by doing an executeOSCommand with command as “java -version”, but this will return the default java version of your system and not neccessarily the version the IS is running on.

See IS Built-In-Services Reference for further informations.

Regards,
Holger

In addition to Holger comments, if you want the java version on which the IS runtime is running use the service “wm.server.query:getSystemAttributes” which pulls the same info. on IS about page.

Any questions?

1 Like