Difference between revisions of "I2Rest Gate URL definition using Unix socket"

From i2Rest
Jump to: navigation, search
Line 1: Line 1:
[[I2Rest_Gates#i2Rest_Gates|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. As an example of such a case -  [[I2Rest_anonymous_sessions|Anonymous session]] (which is an IBM i job serving request to ECHO test program), and i2Rest Session Gate (which is the internal endpoint requested by submited sessions).<br>
+
{{DISPLAYTITLE:Serving incoming connections using Unix sockets}}
In the basic configuration Session Gate is defined by default - when i2Rest Server can't find configuration for some gate, it creates temporary unix socket endpoint at /tmp folder, for example /tmp/AS5WRD7DCJ.<br> Configuration bellow shows how to [[Gate_object|define I2Rest Gate]] URL using Unix socket explicitly.  
+
[[I2Rest_Gates#i2Rest_Gates|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.<br/>
 +
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.<br/> Configuration bellow shows how to define [[Gate_object|i2Rest Gate]] URL using Unix socket explicitly.  
 
;Step 1
 
;Step 1
: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:
+
:''This step is the same as in the basic example. You can skip this step if you've done the basic scenario.''<br/>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:
 
<pre>
 
<pre>
 
<pcml version="1.0">
 
<pcml version="1.0">
Line 14: Line 15:
  
 
;Step 2
 
;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 and pcml_file with appropriate values.
+
: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 <b>bold</b>) with appropriate values.<br/>''Note that IFS file folder must exist, but the file must not. i2Rest Server will create this file automatically.''<br/>For clarity, differences with [[I2Rest_quick_config|Basic configuration]] are highlighted in <span style="background:#D3D3D3;">gray</span>:
[[I2Rest_quick_config|Basic configuration]] with Unix socket defined gate (differences are highlighted in <span style="background:#D3D3D3;">gray</span>):
 
  
 
  {
 
  {
Line 21: Line 21:
 
     {
 
     {
 
       "main"      : {"url":"http://'''<host_name>[:port] (for example api.i2rest.com:1234)'''"},
 
       "main"      : {"url":"http://'''<host_name>[:port] (for example api.i2rest.com:1234)'''"},
       "management" : {"url":"http://'''<host_name>[:port] (for example api.i2rest.com:4321)'''"},
+
       "management" : {"url":"http://'''<host_name>[:port] (for example api.i2rest.com:4321)'''"}<span style="background:#D3D3D3;">,
      <span style="background:#D3D3D3;">"session"    : {"url":"file://'''<IFS file> (for example /i2Rest/Session)'''"}</span>
+
      "session"    : {"url":"file://'''<IFS file> (for example /i2Rest/Session)'''"}</span>
 
     },
 
     },
 
     "session_systems":
 
     "session_systems":

Revision as of 09:36, 8 July 2020

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
      }
   ]
}