Connecting Genie Sessions to Profound.js
Overview
Genie is a Profound UI module that transforms 5250 interfaces to a browser-based HTML5 format on the fly. Genie allows users to start an interactive 5250 session directly within a browser. But beyond presenting 5250 information, Genie can also integrate directly with RPG Open Access Rich Display programs and Node.js modules.
Many features within the Profound.js Connector rely on Genie in order to facilitate a seamless transition between IBM i / 5250 functionality and Node.js. Genie provides a simple way to connect your Profound.js modules to IBM i. More information about Genie is available on the Genie page.
Navigating to Genie
To start a Genie session, navigate to the following URL:
http://puihost:port/profoundui/geniepuihost - The server or host name where Profound UI is installed.
port - The port number used by Profound UI.
This is not the same as the Profound.js server host name and port number.
Calling Node.js from Genie
Genie authenticates users by prompting for an IBM i user ID and password on the standard IBM i Sign On screen. Once a user is signed in and an interactive session is established, calls can be made to Profound.js modules either by using the PJSCALL command or by using a Proxy Program. In order for this to happen, Genie must be able to make a connection to the Profound.js server. Because it is possible to configure multiple Profound.js instances, Genie uses environment variables to control which server to connect to.
Environment Variables in Genie
PROFOUNDJS_COMM_HOST - Specifies the Profound.js host name or IP address to connect to.
PROFOUNDJS_COMM_PORT - Specifies the port number to connect to.
Both environment variables are automatically set at the system level when you first install Profound.js. If you only installed one copy of Profound.js, there is no need to work with environment variables, as they should already point to the correct Profound.js instance.
Each interactive Genie session inherits the system environment variable values, which then become the initial job environment variable values. You can view your current environment variable settings by using the interactive WRKENVVAR command.
You can select option 2 (Change) or use the CHGENVVAR command on PROFOUNDJS_COMM_HOST and PROFOUNDJS_COMM_PORT to change which Profound.js instance to connect to. CHGENVVAR can be used from a command line or in a CL program. This enables you to switch between instances, such as Production, Development, and Test.
The environment variables are changed at the *JOB level by default. In that regard, it is similar to changing a job’s library list, meaning that the change affects the current user’s session only.
HTTP/CGI Environment Variables
By default, if PJSCALL and proxy programs are called within a Genie application or interactive job, and the Profound UI / Genie library is on the library list, any environment variables defined in the Genie HTTP/CGI job are brought over to the calling job. To disable this behavior, set the environment variable PROFOUNDJS_SET_HTTP_VARS=0 in the calling job.
HTTPS in Genie
The
PROFOUNDJS_COMM_VERIFYPEERandPROFOUNDJS_COMM_VERIFYHOSTenvironment variables were added in Profound.js 5.8.2.The
PROFOUNDJS_COMM_KEYRINGenvironment variable was added in Profound.js 6.The
PROFOUNDJS_COMM_VERIFYHOSTenvironment variable is no longer available starting in Profound.js 6.
In order to specify that Genie should connect via HTTPS, use the PROFOUNDJS_COMM_SECURE environment variable. To use HTTPS, set PROFOUNDJS_COMM_SECURE to 1.
Certificate Authorities
The default SSL CA (certificate authority) certificates that Profound.js trusts are bundled with the product. The bundle includes the well known CAs, and so should work fine if your server SSL certificate is issued by a well known authority. If your server is using a certificate issued by an unknown authority (such as a local or self-managed authority), you can override the CA certificates by setting the PROFOUNDJS_COMM_KEYRING environment variable. This variable can be set either to a file path on the IFS or to the special value *SYSTEM, to use the CAs from the Digital Certificate Manager’s *SYSTEM store. The keyring file must be in the IBM key database (KDB) format. For example:
Use *SYSTEM store for CAs
ADDENVVAR ENVVAR(PROFOUNDJS_COMM_KEYRING) VALUE(*SYSTEM)Use alternate KDB file for CAs
ADDENVVAR ENVVAR(PROFOUNDJS_COMM_KEYRING) VALUE('/MyDir/MyCAs.kdb')It is recommended to use the built-in CA bundle (rather than the *SYSTEM store) if your server certificate is issued by a well known authority. The built-in CA bundle is more extensive and up to date than the default CAs configured by IBM.
Disabling Verification
By default, the Profound.js Connector verifies that the server’s SSL certificate is issued by a trusted authority, and that the host name used on the request matches the host name the server’s certificate was issued for. This ensures secure communications. However, in some cases (for example, when using a self-signed server certificate) it may be necessary to disable these verifications. The following environment variables can be used:
PROFOUNDJS_COMM_VERIFYPEER - Set to
0to disable SSL certificate verification.PROFOUNDJS_COMM_VERIFYHOST - Set to
0to disable SSL host name verification.
Disabling SSL certificate and host name verification makes communications insecure and is strongly discouraged. Do not disable these verifications unless you understand and accept the risks.
Connecting to a Development Instance on Your PC
It is often convenient to set up a development instance of Profound.js on your personal computer. You can then use PC-based development and debugging tools, such as VS Code. The PJSMYIP command, located within your Profound.js install library, can automatically detect your PC’s IP address and change the PROFOUNDJS_COMM_HOST environment variable for you. However, you may have to manually specify the port number of the Profound.js server running on your PC.
The following example shows how to point your Genie session to a Profound.js instance running on port 8081 on your PC.
If your PC is on a different network than IBM i and is not connected to VPN, the PJSMYIP command will not be able to determine your PC’s IP address. The PC network’s edge router or firewall IP address is returned instead. In this case, the PC network must be configured to route the connections to the PC using port forwarding or NAT.