Feedback
Did this article resolve your question/issue?

   

Article

How to find the login broker a remote client initially connected to ?

« Go Back

Information

 
TitleHow to find the login broker a remote client initially connected to ?
URL NameP96368
Article Number000140968
EnvironmentProduct: Progress
Version: 8.x, 9.x
Product: OpenEdge
Version: All Supported Versions
OS: All Supported Platforms
Question/Problem Description
How to find the login broker a remote client initially connected to ?
How to find which login broker spawned a specific remote client server ?
How to find which remote client is connected to which remote server ?
Which VST displays information about client server connections ?
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution
When more than one Login Broker is started, there is no direct link that can be used to establish "which login broker spawned" a specific remote server that was needed for a remote client connection.

One method of associating servers with the Login Broker which started them would be to explicitly define a unique -minport -maxport range when starting each login broker.  Then, the _servers._server-portnum VST can be used to identify which Login Broker (BROKER 0, BROKER <n>), started any given remote server.

The below code assumes the database was started using the following parameters:
{primary login broker}:       
proserve dbname <..startup parameters..> -S 10000 -minport 10001 -maxport 10099
{secondary login broker}:  
proserve dbname -m3 <..startup parameters..> -S 10100 -minport 10101 -maxport 10199
{tertiary login broker}:
proserve dbname -m3 <..startup parameters..> -S 10200 -minport 10201 -maxport 10299

Note that, only relevant parameters to this discussion are listed here.

The following example code uses the _connect and _servers Virtual System Tables (VST) to find the following:
  • Which Login Broker a remote client connected to when they accessed the database.
  • The Remote Server that remote client is currently connected to
  • The Port Number of the remote server in relation to the port number of the Login Broker.
DEFINE TEMP-TABLE ttServers NO-UNDO
    FIELD tiServerNum  AS INTEGER   LABEL "SVR_num"     FORMAT ">>9"
    FIELD tiServerPid  AS INTEGER   LABEL "Server Pid"  FORMAT ">>>>>>>>>9"
    FIELD tcServerType AS CHARACTER LABEL "Server Type" FORMAT "x(14)"
    FIELD tiPortNum    AS INTEGER   LABEL "Port Number" FORMAT ">>>>>>>>>9"
    FIELD tiParentSrv  AS INTEGER   LABEL "Parent Srv"  FORMAT ">>9"
    FIELD tiNumUsers   AS INTEGER   LABEL "Num Users"
    FIELD tiMaxUsers   AS INTEGER   LABEL "Max Users"
    INDEX idxServers IS PRIMARY UNIQUE tiPortNum.

DEFINE BUFFER buffServers FOR ttServers.

DEFINE QUERY qBrokers FOR ttServers SCROLLING.
DEFINE BROWSE bBrokers QUERY qBrokers
    DISPLAY ttServers.tiServerNum LABEL "Broker"
            ttServers.tiServerPid LABEL "PID"
            ttServers.tcServerType
            ttServers.tiPortNum
            ttServers.tiNumUsers
            ttServers.tiMaxUsers
    WITH 2 DOWN WIDTH 78 TITLE "Brokers".

DEFINE QUERY qServers FOR buffServers SCROLLING.
DEFINE BROWSE bServers QUERY qServers
    DISPLAY buffServers.tiServerNum LABEL "Server"
            buffServers.tiServerPid LABEL "PID"
            buffServers.tcServerType
            buffServers.tiPortNum
            buffServers.tiNumUsers
            buffServers.tiMaxUsers
    WITH 8 DOWN WIDTH 78 TITLE "Servers".

DEFINE QUERY qUsers FOR _connect SCROLLING.
DEFINE BROWSE bUsers QUERY qUsers
    DISPLAY _connect-server LABEL "Server Num"
            _Connect-ClientType   LABEL "Type"
            _connect-pid    LABEL "PID"
            _connect-device LABEL "Device"
            _connect-usr    LABEL "User Num"
            _connect-name   LABEL "User ID"
            SUBSTRING(_connect-time,5,6) LABEL "Conn Date" 
            SUBSTRING(_connect-time,12,8) LABEL "Conn Time"
    WITH 8 DOWN WIDTH 78 TITLE "Connected Users".

DEFINE FRAME fBrokersAndServers bBrokers SKIP(1)
                                bServers SKIP(1)
                                bUsers
    WITH THREE-D TITLE "Servers by Broker".

DEFINE VARIABLE iParentSrv AS INTEGER     NO-UNDO.

ON VALUE-CHANGED OF BROWSE bBrokers DO:
  IF NOT AVAILABLE ttServers THEN DO:
    CLOSE QUERY qServers.
    LEAVE.
  END.

  OPEN QUERY qServers FOR EACH buffServers 
      WHERE buffServers.tiParentSrv EQ ttServers.tiServerNum
      BY tiPortNum.
  APPLY "VALUE-CHANGED" TO BROWSE bServers.
END.

ON VALUE-CHANGED OF BROWSE bServers DO:
  IF NOT AVAILABLE buffServers THEN DO:
    CLOSE QUERY qUsers.
    LEAVE.
  END.

  OPEN QUERY qUsers FOR EACH _connect
      WHERE _connect._connect-server EQ buffServers.tiServerNum
      BY _connect-time.
END.

/* Sort by Port Number in order to read and identify the servers and brokers in order */
FOR EACH _servers NO-LOCK 
    WHERE _servers._Server-type NE "Inactive" BY _Servers._Server-PortNum:

  /* This is a Broker */
  IF _servers._server-type NE "LOGIN" THEN DO:
    IF _servers._server-portnum GT 10000 AND 
       _servers._server-portnum LT 10100 THEN
      iParentSrv = 0.
    ELSE IF _servers._server-portnum GT 10100 AND
            _servers._server-portnum LT 10200 THEN
      iParentSrv = 1.
    ELSE iParentSrv = 2.
  END.
  ELSE iParentSrv = ?.

  CREATE ttServers.
  ASSIGN ttServers.tiServerNum  = _servers._server-num
         ttServers.tiServerPid  = _servers._server-pid
         ttServers.tcServerType = _servers._server-type
         ttServers.tiPortNum    = _servers._server-portnum
         ttServers.tiParentSrv  = iParentSrv
         ttServers.tiNumUsers   = _servers._server-currusers
         ttServers.tiMaxUsers   = _servers._server-maxusers.
END.

OPEN QUERY qBrokers FOR EACH ttServers 
    WHERE ttServers.tcServerType EQ "LOGIN"
    BY ttServers.tiPortNum.

ENABLE ALL WITH FRAME fBrokersAndServers.
APPLY "ENTRY" TO BROWSE bBrokers.

WAIT-FOR CLOSE OF THIS-PROCEDURE.


 
Workaround
Notes
Last Modified Date8/27/2020 7:49 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.