Solved

Determine rules service port inside the rules service?


Anyone know of a way inside the rules service itself to determine on which port it is running?

icon

Best answer by robert.hellinx 1 June 2022, 13:04

View original

2 replies

Exactly what I was looking for, thanks @robert.hellinx !

Userlevel 2
Badge +2

Hi Marc,

USoft has an off-the-shelf component OTS_WIN_PORT_INFO that returns information about port numbers.
When you import this component, it will add a component table too.

To find the Port number of your Rulesservice, you need its Process ID. I used a small .Net (C#) component to get that ID:

using System;
using System.Diagnostics;

class PRC_UTIL
{
public static int ProcessId
{
get
{
if (_processId == null)
{
using(var thisProcess = System.Diagnostics.Process.GetCurrentProcess())
{
_processId = thisProcess.Id;
}
}
return _processId.Value;
}
}
private static int? _processId;
}

Please, use a better class name (or add the method to an existing class). 😆

With these two components you can create a query like:

select
*
from
OTS_WIN_PORT_INFO "wpio"
where
wpio.PROCESSID = PRC_UTIL.GET_PROCESSID()
;

This will retrieve all ports in use by the rules service. The port that is 'LISTENING' is your rules service port number. (wpio.STATE = 'LISTENING'). You can test this from the browser:

http://{hostname}:{portnumber}/{APPLICATION}/{USERNAME}/plain/SqlScript?$Password={pwd}&$SQL=select * from OTS_WIN_PORT_INFO "wpio" where wpio.PROCESSID = OTS_UTIL.GET_PROCESSID() and wpio.STATE = 'LISTENING'

Hope this helps.


Regards,

Robert

 

Reply