Which server am I connected to?

I have seen a lot of functions that give information on the servers, but the one i am looking for is elusive.

ServerIsOnline wil give me the status of the servers - both the primary and standby.

However, I am only communicating to one of them at a time.

How would I find out which one I am talking to?

Parents
  • Hi Michael,

    The concept of primary and standby is different for every Citect process (Alarm Server, Trend Server, Report Server and I/O Servers).
    A client could be connected to the primary trend server as well as the standby alarm server. For I/O it's even more complicated because there is no primary or standby server as such. Each I/O device can have a primary and a standby definition, and these can reside on any I/O server in your setup.

    If you want to know what I/O server your client is talking to for a specific I/O device, you can use the following function:

    sCurrentIOServer = IODeviceInfo(sIODevice, 17); // returns the name of the active I/O server

    This syntax only works if your primary and standby I/O devices are configured with the exact same name.
    If the names of a redundant I/O device pair are not the same, you first have to find out the I/O device number (aka unit number) before you can find the active server:

    iUnitNr = StrToInt(IODeviceInfo(sIODevice, 11)); // returns the I/O device number
    sCurrentIOServer = IODeviceInfo(iUnitNr, 17); // returns the name of the active I/O server

    To find out which Alarm server you are connected to use:

    bConnectedToStandbyServer = StrToInt(ServerInfo("Alarm", 2); // returns 0 if connected to primary server, otherwise 1

    This works for Trend and Report servers as well, just replace the word "Alarm" with "Trend" or "Report".
Reply
  • Hi Michael,

    The concept of primary and standby is different for every Citect process (Alarm Server, Trend Server, Report Server and I/O Servers).
    A client could be connected to the primary trend server as well as the standby alarm server. For I/O it's even more complicated because there is no primary or standby server as such. Each I/O device can have a primary and a standby definition, and these can reside on any I/O server in your setup.

    If you want to know what I/O server your client is talking to for a specific I/O device, you can use the following function:

    sCurrentIOServer = IODeviceInfo(sIODevice, 17); // returns the name of the active I/O server

    This syntax only works if your primary and standby I/O devices are configured with the exact same name.
    If the names of a redundant I/O device pair are not the same, you first have to find out the I/O device number (aka unit number) before you can find the active server:

    iUnitNr = StrToInt(IODeviceInfo(sIODevice, 11)); // returns the I/O device number
    sCurrentIOServer = IODeviceInfo(iUnitNr, 17); // returns the name of the active I/O server

    To find out which Alarm server you are connected to use:

    bConnectedToStandbyServer = StrToInt(ServerInfo("Alarm", 2); // returns 0 if connected to primary server, otherwise 1

    This works for Trend and Report servers as well, just replace the word "Alarm" with "Trend" or "Report".
Children
No Data