Serving incoming connections using Unix sockets
Revision as of 09:36, 8 July 2020 by Alexei.baranov (talk | contribs)
i2Rest Server Gates are able to listen incoming requests at some unix socket defined as a file at IFS. In this case, the server gate will not be accessible externally, so your i2Rest Server instance and its clients both should be located on the same IBM i server. This is typically used for interaction of i2Rest Server and local session jobs.
We have no settings for session gate in the basic configuration. When i2Rest Server can't find configuration for some gate, it creates temporary unix socket endpoint at /tmp folder, for example /tmp/AS5WRD7DCJ.
Configuration bellow shows how to define i2Rest Gate URL using Unix socket explicitly.
- Step 1
- This step is the same as in the basic example. You can skip this step if you've done the basic scenario.
Create text file named I2RESTECHO.PCML anywhere on IFS, for example "/tmp/PCML/i2restecho.pcml". Copy and paste following code. It represents a description for the sample program I2RESTECHO, that is included into i2Rest Server installation for demonstration purposes:
<pcml version="1.0"> <program name="echo" path="/QSYS.LIB/%LIBL%.LIB/I2RESTECHO.PGM"> <data name="echo" usage="inputoutput" type="char" length="10" trim="both"/> </program> </pcml>
- Step 2
- Contact your system administrator for your IBM i server host name (or IP) and two available ports for "main" and "management" gates of your first i2Rest Server instance. Create file config.json (you can name it with any name and put it into any available IFS folder). Enter following text, replace host_name, ports pcml_file and IFS file (highlighted with bold) with appropriate values.
Note that IFS file folder must exist, but the file must not. i2Rest Server will create this file automatically.
For clarity, differences with Basic configuration are highlighted in gray:
{
"gates":
{
"main" : {"url":"http://<host_name>[:port] (for example api.i2rest.com:1234)"},
"management" : {"url":"http://<host_name>[:port] (for example api.i2rest.com:4321)"},
"session" : {"url":"file://<IFS file> (for example /i2Rest/Session)"}
},
"session_systems":
[
{ "name" : "*ANONYMOUS",
"submit" : "SBMJOB JOB(I2RESTA) \
USER(${user}) \
CMD(CALL I2REST \
PARM('-session' \
'-url' '${surl}' \
'-uid' '${uid}' \
'-user' '${user}')) \
INLLIBL(I2REST)"
}
],
"pcmls":
[
{
"pcml_mount" : "echo",
"pcml_file" : "<complete name of i2restecho.pcml on IFS (for example /tmp/PCML/i2restecho.pcml)>",
"valid_in_anonymous" : true
}
]
}