IBM HTTP instance for Node JS 8

Issue #43 resolved
Former user created an issue

We need to create IBM HTTP server instance for Node JS 8 please advise how to do it.

Comments (64)

  1. Jesse G

    Are you asking about how to create an instance of the builtin Apache server (administered through HTTPAdmin) for Node js?

  2. mengxumx Account Deactivated

    If you want to use the IBM HTTP server instance as a front-end and forward requests to the back-end Node.js applications. You can use the FastCGI addon to connect them. There is an article for that but I can not find the English version right now.

    If you want to create a Node.js HTTP server instance from the WebAdmin GUI, it is not supported yet.

  3. Iftikhar Ahmed

    Dear Xu Meng I am looking for article on below link which I am not able to found if you know how to do that please write down the steps for me I want to run Node.js 8 with IBM HTTP Server for i thanks & Regards.

    Running Node.js with IBM HTTP Server for i

  4. Iftikhar Ahmed

    I could not understand the Chinese if you can translate it in English for me it is great help I don't know why IBM is remove English version of this article.

  5. mengxumx Account Deactivated

    @sheikhifti , we can call npm install node-fastcgi to install node-fastcgi for Node.js 8/10.

    I am trying to draft an example for that.

  6. Iftikhar Ahmed

    npm install node-fastcgi
    [K [?25h [37;40mnpm [0m [0m [30;43mWARN [0m [35m [0m nodejs_expressjs@1.0.0 No descriptionfastcgi@1.3.3~postinsta [0m [K [K
    [0m [37;40mnpm [0m [0m [30;43mWARN [0m [35m [0m nodejs_expressjs@1.0.0 No repository field.
    [0m
    + node-fastcgi@1.3.3
    updated 1 package in 6.716s
    Where it will be located

  7. Iftikhar Ahmed

    Please send me the example how to run Node JS 8 on HTTP IBM i Server I am waiting for your reply.

  8. Iftikhar Ahmed

    I could not see any button to download or clone the project please advise how can I put it in IBM i System.

  9. mengxumx Account Deactivated

    If you have git installed, you can run git clone git@github.com:IBM/ibmi-oss-examples.git in PASE and then you will get the whole ibmi-oss-example project. And then you can cd ibmi-oss-examples/nodejs/node_fastcgi

    Otherwise you need to install git first -- yum install git

  10. Iftikhar Ahmed

    I have install node-fastcgi in the location "/QOpenSys/pkgs/lib/nodejs8/lib/node_modules/node-fascgi" and provided example is in the folder "/home/iftikhar/node_fastcgi" need to change any thing in the provided example please advise.

  11. Iftikhar Ahmed

    I am getting the below error while running the index.js please advise.

    node index.js
    module.js:550
    throw err;
    ^

    Error: Cannot find module 'node-fastcgi'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/iftikhar/node_fastcgi/index.js:3:14) at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    $
    node index.js
    module.js:550
    throw err;
    ^

    Error: Cannot find module '/QOpenSys/pkgs/lib/nodejs8/lib/node_modules/node-fascgi'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/iftikhar/node_fastcgi/index.js:3:14)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    $

  12. mengxumx Account Deactivated

    Did you run the command npm i in the project directory? This should install all the dependencies in current directory and then index.js can automatically find them using require('node-fastcgi')

    It is not recommended to install any addon to the global path /QOpenSys/pkgs/lib/nodejs8/lib/node_modules/. If you insist, you may try to run export NODE_PATH=/QOpenSys/pkgs/lib/nodejs8/lib/node_modules first, and then index.js should find it using require('node-fastcgi').

  13. Iftikhar Ahmed

    Thanks it is working now after installing all the dependencies now what is the setup for to develop new Node JS 8 application where to put the code JS, htm and hbc etc how it will run on that HTTP server what will be the path and root directory.

  14. mengxumx Account Deactivated

    Do you mean how to setup the front-end HTTP Server instance? I think it is already described here.

  15. Iftikhar Ahmed

    No it setup already I want to know where can I put my Node JS application code (JS, html, hbs) need to run on that front end HTTP server.

  16. mengxumx Account Deactivated

    The html files are located in the htdocs folder (e.g. /www/fastcgi/htdocs) and only the front-end HTTP server can access them.

    The js code are located in the node.js project folder (e.g. /home/iftikhar/node_fastcgi) and only the back-end Node.js server can access them.

    It depends on which requests you want be handled by the front-end and which are handled by the back-end.

  17. Iftikhar Ahmed

    When I stop the index.js then application is not running how can we keep it running without interactive session I am running it from qshell when I exit from qshell it ended the index.js and application is giving error but server is continue to run. Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.

    Contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

    More information about this error may be available in the server error log.

  18. mengxumx Account Deactivated

    I think you can try to run this CL command to submit a job running in background --

    SBMJOB CMD(QSH CMD('/QOpenSys/pkgs/bin/node /home/iftikhar/node_fastcgi/index.js'))
    

    If you want to check / end the job, you can call wrkactjob sbs(qbatch) and find the PGM-node job.

    Opt  Subsystem/Job  User        Type  CPU %  Function        Status
       QBATCH         QSYS        SBS      .0                   DEQW
         QDFTJOBD     XUMENG      BCH      .0  CMD-QSH          TIMW
         QP0ZSPWP     XUMENG      BCI      .0  PGM-node         SELW 
         QZSHSH       XUMENG      BCI      .0  PGM-QZSHSH       EVTW 
    
  19. Iftikhar Ahmed

    If we did changes in the application to take affect these changes we need to End this job and re-run again or just restart the server.

  20. mengxumx Account Deactivated

    If you only changed the js code, you do not need to restart the HTTP server. Just re-run the Node.js job.

  21. Iftikhar Ahmed

    It means that we need to end and re-run the above submitted job every time after changing the js code it is not possible that it will automatically detected the change using nodemon.

  22. Iftikhar Ahmed

    when we submit the node js and its running in batch job and then run the index.html it gives the server internal error and the node js submitted job is ended itself.

  23. Iftikhar Ahmed

    I remember when I configure the server for Node JS 6 I didn't run the any node js job only configure the HTTP server and modify the few conf files.

  24. Iftikhar Ahmed

    Yes I have check I have run node js job also for Node JS 6. but here problem is that when we running the node js job in batch it is not working please advise.

  25. mengxumx Account Deactivated

    If you run HTTP server and Node.js server at the same system, you may try to use the Local Mode.

    In this mode, the Node.js server instance will be invoked by the HTTP server automatically.

    Follow the same steps of remote mode to set up the environment.

    That means you already have the HTTP server instance FASTCGI and the Node.js project (/home/iftikhar/node_fastcgi) ready. Do not forget to run npm i to install the dependencies.

    Give HTTP server authority to access your Node.js code

    CHGOWN OBJ('/home/iftikhar/node_fastcgi') NEWOWN(QSYS) SUBTREE(*ALL)
    CHGAUT OBJ('/home/iftikhar/node_fastcgi') USER(QTMHHTTP) DTAAUT(*RX) SUBTREE(*ALL)
    

    Change index.js to listen to stdin (local mode)

    fcgiServer.listen();  //Local mode
    // fcgiServer.listen(8088);  //Remote mode
    

    Change fastcgi.conf to disable remote mode and enable local mode. And specify the path of your index.js correctly.

    ; Local Mode --the HTTP server should run at the same IP address with the FastCGI server.
    Server type="application/x-httpd-javascript" CommandLine="/www/fastcgi/conf/index.js" StartProcesses="1"
    
    ; Remote Mode --the FastCGI server can run at different IP addresses. Set 'Binding=' to the IP/port that the FastCGI server listens to.
    ; ExternalServer type="application/x-httpd-javascript" Binding="127.0.0.1:8088" ConnectionTimeout="300" RequestTimeout="300"
    
    ; Where to place socket files
    IpcDir /www/fastcgi/logs
    

    Then you do not need to manually call node index.js to start the Node.js server. You just need to start the HTTP server and submit a HTTP request. The Node.js server will be launched automatically.

  26. Iftikhar Ahmed

    I have run the npm i and all the dependencies are installed in project directory I have performed all the above steps but when I start the HTTP server it not starting showing still stop status I have tried several time but HTTP server not getting started please advise.

  27. Iftikhar Ahmed

    Dear Xu Meng I have enables the multithread then server start running normal but when I have submitted HTTP request is not giving the correct value please see attached.

    [Fri Apr 26 12:07:21.370024 2019] [core:error] [pid 5889175:tid 0000003F] [client 10.6.227.35:57620] ZSRV_MSG0016: URI in request GET /favicon.ico HTTP/1.1 is not valid, referer: http://10.200.65.227:8383/dspsysval.jsx?key=QDAY [Fri Apr 26 12:07:55.155424 2019] [mpm_worker:notice] [pid 5889172:tid 000001CE] ZSRV_MSG0385: Apache/2.4.20 (IBM i) configured -- resuming normal operations.

    After giving the HTTP request. http://10.200.65.227:8383/dspsysval.jsx?key=QDATETIME QDATETIME = undefined

  28. Iftikhar Ahmed

    It is running as shown below it is correct or not. Subsystem/Job User Type CPU % Function Status FASTCGI QTMHHTTP BCH .0 PGM-QZHBMAIN SIGW
    FASTCGI QTMHHTTP BCI .0 PGM-QZSRLOG SIGW
    FASTCGI QTMHHTTP BCI .0 PGM-QZSRLOG SIGW
    FASTCGI QTMHHTTP BCI .0 PGM-QZSRHTTP SIGW
    FASTCGI QTMHHTTP BCI .0 PGM-zfcgi SELW
    FASTCGI QTMHHTTP BCI .2 PGM-node SELW
    FASTCGI QTMHHTTP BCI .3 PGM-QZSRHTTP SIGW FASTCGI QTMHHTTP BCI .0 PGM-zfcgi FASTCGI QTMHHTTP BCI .9 PGM-node

  29. Iftikhar Ahmed

    it if also giving the below error log.

    /www/fastcgi/logs/error_zfcgi.Q5889245

    **Beginning of data**
    kill(-5889246, SIGUSR1) failed - [3] No such process
    *End of Data*****

  30. Iftikhar Ahmed

    I am getting the below error.

    [Mon Apr 29 09:30:17.220040 2019] [core:error] [pid 5889285:tid 00000052] [client 10.6.227.35:55024] ZSRV_MSG0016: URI in request GET /favicon.ico HTTP/1.1 is not valid, referer: http://10.200.65.227:8383/dspsysval.jsx?key=QCCSID [Mon Apr 29 10:33:20.917168 2019] [core:error] [pid 5889285:tid 00000052] [client 10.6.227.35:57609] ZSRV_MSG0016: URI in request GET /favicon.ico HTTP/1.1 is not valid, referer: http://10.200.65.227:8383/dspsysval.jsx?key=QCCSID

    http://10.200.65.227:8383/dspsysval.jsx?key=QDATETIME

    QDATETIME = undefined

  31. mengxumx Account Deactivated

    Would you check your fastcgi.conf to see if the CommandLine is the correct path of your index.js? I manually copied index.js to the conf folder but your index.js would not be here.

    ; Local Mode --the HTTP server should run at the same IP address with the FastCGI server.
    Server type="application/x-httpd-javascript" CommandLine="/www/fastcgi/conf/index.js" StartProcesses="1"
    
  32. Iftikhar Ahmed

    The below is the path of the Index.js

    Browse : /www/fastcgi/conf/index.js

    Browse : /www/fastcgi/conf/fastcgi.conf

    ************Beginning of data**************

    ; Local Mode --the HTTP server should run at the same IP address with the FastCGI server.

    Server type="application/x-httpd-javascript" CommandLine="/www/fastcgi/conf/index.js" StartProcesses="1"

    ; Remote Mode --the FastCGI server can run at different IP addresses. Set 'Binding=' to the IP/port that the FastCGI server listens to.

    ; ExternalServer type="application/x-httpd-javascript" Binding="127.0.0.1:8088" ConnectionTimeout="300" RequestTimeout="300"

    ; Where to place socket files

    IpcDir /www/fastcgi/logs

    End of Data********

    Server is running when we hit the url the below is coming.

    http://10.200.65.227:8383/dspsysval.jsx?key=QDATETIME

    QDATETIME = undefined

  33. mengxumx Account Deactivated

    If you put the index.js file to /www/fastcgi/conf/index.js, then you need to put all the other files in the same directory and rum npm init -y and npm i. Otherwise index.js can not find the dependencies.

  34. mengxumx Account Deactivated

    So it is recommended to directly use the Node.js project folder (e.g. /home/name/node_fastcgi). You can change the path /home/name/node_fastcgi in below code to your real directory of the node_fastcgi project.

    In this project folder, call npm i to install the dependencies.

    Give HTTP server authority to access your Node.js code

    CHGOWN OBJ('/home/name/node_fastcgi') NEWOWN(QSYS) SUBTREE(*ALL)
    CHGAUT OBJ('/home/name/node_fastcgi') USER(QTMHHTTP) DTAAUT(*RX) SUBTREE(*ALL)
    

    Change index.js to listen to stdin

    fcgiServer.listen();  //Local mode
    // fcgiServer.listen(8088);  //Remote mode
    

    Change fastcgi.conf to disable remote mode and enable local mode. And specify the path of your index.js correctly.

    ; Local Mode --the HTTP server should run at the same IP address with the FastCGI server.
    Server type="application/x-httpd-javascript" CommandLine="/home/name/node_fastcgi/index.js" StartProcesses="1"
    
    ; Remote Mode --the FastCGI server can run at different IP addresses. Set 'Binding=' to the IP/port that the FastCGI server listens to.
    ; ExternalServer type="application/x-httpd-javascript" Binding="127.0.0.1:8088" ConnectionTimeout="300" RequestTimeout="300"
    
    ; Where to place socket files
    IpcDir /www/fastcgi/logs
    

    And then start your HTTP server instance FASTCGI.

  35. Iftikhar Ahmed

    npm i

    cd '/home/iftikhar/node_fastcgi' $ > npm i [K [?25h [27m [90m...... [0m] \ build:needle: [34;40mverb [0m [35mlinkBins [0m [ { needle: './bin/needle' } [0m [K > idb-connector@1.1.10 install /home/iftikhar/node_fastcgi/node_modules/idb-connector > node-pre-gyp install --fallback-to-build [37;40mnode-pre-gyp [0m [0m [30;43mWARN [0m [0m [35mUsing needle for node-pre-gyp https download [0m [0m[idb-connector] Success: "/home/iftikhar/node_fastcgi/node_modules/idb-connector/lib/binding/Release/node-v57-ibmi-ppc64/db2i a.node" already installed Pass --update-binary to reinstall or --build-from-source to recompile [K [?25h [37;40mnpm [0m [0m [34;40mnotice [0m [35m [0m created a lockfile as package-lock.json. You should commit this file.[K [0m [37;40mnpm [0m [0m [30;43mWARN [0m [35m [0m node_fastcgi@1.0.0 No repository field. [0m

    added 72 packages from 71 contributors in 15.539s $

  36. Iftikhar Ahmed

    http://10.200.65.227:8383/dspsysval.jsx?key=QDATETIME

    after giving the URL request below error is encounter

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

    More information about this error may be available in the server error log.

  37. Iftikhar Ahmed

    Error Log

    [Tue May 07 15:25:06.135040 2019] [mpm_worker:notice] [pid 8931034:tid 0000002F] ZSRV_MSG0385: Apache/2.4.20 (IBM i) configured -- resuming normal operations.

    [Tue May 07 15:28:31.512424 2019] [zend_enabler:error] [pid 8931037:tid 00000E9C] Can not find binding for type='application/x-httpd-javascript' path='/www/fastcgi/htdocs/dspsysval.jsx' (-196583.135)

  38. Iftikhar Ahmed

    /www/fastcgi/conf/httpd.conf

    # Configuration originally created by Create HTTP Server wizard on Wed Apr 24 10:35:39 GMT+05:00 2019

    LoadModule zend_enabler_module /QSYS.LIB/QHTTPSVR.LIB/QZFAST.SRVPGM

    AddType application/x-httpd-javascript .jsx

    AddHandler fastcgi-script .jsx

    Listen 10.200.65.227:8383

    DocumentRoot /www/fastcgi/htdocs

    TraceEnable Off

  39. mengxumx Account Deactivated

    You need to copy the fastcgi.conf file to /www/fastcgi/conf/

    This file is not part of the Node.js project, but a configuration file of the HTTP server. It tells the HTTP server where to find the back-end application to handle FastCGI requests.

  40. mengxumx Account Deactivated

    Below are the structures of the two folders (HTTP instance and the Node.js project).

    The files with marker * are the only 3 files which need your modifications.

    The node_modules folder contains all the dependencies of the node_fastcgi project. You can call npm i in the node_fastcgi folder to get it installed.

    /www/fastcgi
    |-- conf
    |   |-- fastcgi.conf *  (copied from the node_fastcgi folder)
    |   `-- httpd.conf *
    |-- htdocs
    |   `-- index.html
    `-- logs
    
    /home/xumeng/git/ibmi-oss-examples/nodejs/node_fastcgi/
    |-- README.md
    |-- dspsysval.js
    |-- fastcgi.conf ( just a template, copy it to your HTTP conf folder)
    |-- index.js *
    |-- node_modules  ( call `npm i` to get these dependencies )
    |   |-- bufferlist
    |   |-- fastcgi-stream
    |   |-- idb-connector
    |   |-- itoolkit
    |   |-- node-addon-api
    |   `-- node-fastcgi
    |-- package-lock.json
    `-- package.json
    

    All the files in the node_fastcgi folder and the fastcgi.conf file in the HTTP conf folder should be given below authorities --

    CHGOWN OBJ('/home/xumeng/git/ibmi-oss-examples/nodejs/node_fastcgi/') NEWOWN(QSYS) SUBTREE(*ALL)
    CHGAUT OBJ('/home/xumeng/git/ibmi-oss-examples/nodejs/node_fastcgi/') USER(QTMHHTTP) DTAAUT(*RX) SUBTREE(*ALL)
    
    CHGOWN OBJ('/www/fastcgi/conf/fastcgi.conf') NEWOWN(QSYS) SUBTREE(*ALL)
    CHGAUT OBJ('/www/fastcgi/conf/fastcgi.conf') USER(QTMHHTTP) DTAAUT(*RX) SUBTREE(*ALL)
    
    Object . . . . . . . . . . . . :   /www/fastcgi/conf/fastcgi.conf
    Type . . . . . . . . . . . . . :   STMF                          
    Owner  . . . . . . . . . . . . :   QSYS                          
    Primary group  . . . . . . . . :   *NONE                         
    Authorization list . . . . . . :   *NONE                            
    
                       Data     --Object Authorities--               
    Opt  User        Authority  Exist  Mgt  Alter  Ref               
    
         *PUBLIC     *RX                                             
         QSYS        *RWX         X     X     X     X                
         QTMHHTTP    *RX                                             
    
    Object . . . . . . . . . . . . :   /home/xumeng/git/ibmi-oss-examples/nodejs/node_fastcgi/
    Type . . . . . . . . . . . . . :   DIR                                       
    Owner  . . . . . . . . . . . . :   QSYS                                      
    Primary group  . . . . . . . . :   *NONE                                     
    Authorization list . . . . . . :   *NONE                                     
    
                       Data     --Object Authorities--                           
    Opt  User        Authority  Exist  Mgt  Alter  Ref                           
    
         *PUBLIC     *RX          X     X     X     X                            
         QSYS        *RWX         X     X     X     X                            
         QTMHHTTP    *RX                                                         
    

    Then you can edit the index.js file and the /www/fastcgi/conf/fastcgi.conf file to choose the running mode

    And ensure that the CommandLine="/home/xumeng/git/ibmi-oss-examples/nodejs/node_fastcgi/index.js" in the /www/fastcgi/conf/fastcgi.conf file is correctly set to your node_fastcgi/index.js path.

  41. Iftikhar Ahmed

    Dear Xu Meng,

    I have done exactly you have described but still not success below is the my structure and error log.

    Work with Active Jobs after giving HTTP request.

    FASTCGI QTMHHTTP BCH .1 PGM-QZHBMAIN SIGW

    FASTCGI QTMHHTTP BCI .0 PGM-QZSRLOG SIGW

    FASTCGI QTMHHTTP BCI .0 PGM-QZSRLOG SIGW

    FASTCGI QTMHHTTP BCI .1 PGM-QZSRHTTP SIGW

    FASTCGI QTMHHTTP BCI .0 PGM-zfcgi SELW

    FASTCGI QTMHHTTP BCI .6 PGM-node SELW

    FASTCGI QTMHHTTP BCI .1 PGM-QZSRHTTP SIGW

    FASTCGI QTMHHTTP BCI .0 PGM-zfcgi SELW

    FASTCGI QTMHHTTP BCI .5 PGM-node SELW

    http://10.200.65.227:8383/dspsysval.jsx?key=QDATETIME

    QDATETIME = undefined

    /www/fastcgi/logs

    [Wed May 08 11:03:43.030064 2019] [zend_enabler:notice] [pid 8931666:tid 00001496] Using [Zend Enabler module, Version 1.3.1] from [Zend Technologies Ltd.]

    [Wed May 08 11:04:26.103968 2019] [mpm_worker:notice] [pid 8931660:tid 00017476] ZSRV_MSG0385: Apache/2.4.20 (IBM i) configured -- resuming normal operations.

    /www/fastcgi/conf/fastcgi.conf

    ; Local Mode --the HTTP server should run at the same IP address with the FastCGI server.

    Server type="application/x-httpd-javascript" CommandLine="/home/iftikhar/node_fastcgi/index.js" StartProcesses="1"

    ; Remote Mode --the FastCGI server can run at different IP addresses. Set 'Binding=' to the IP/port that the FastCGI server listens to.

    ; ExternalServer type="application/x-httpd-javascript" Binding="127.0.0.1:8088" ConnectionTimeout="300" RequestTimeout="300"

    ; Where to place socket files

    IpcDir /www/fastcgi/logs

    End of Data********

    /home/iftikhar/node_fastcgi/index.js

    #!/QOpenSys/pkgs/bin/node

    const fcgi = require('node-fastcgi');

    const url = require('url');

    const fs = require('fs');

    ……………………..

    ……………………..

    fcgiServer.listen(); //Local mode

    // fcgiServer.listen(8088); //Remote mode

    ************End of Data********************

    Project Folder:

    /home/iftikhar/node_fastcgi

       .gitignore             STMF 
       dspsysval.js           STMF 
       index.js               STMF 
       node_modules           DIR  
          bufferlist             DIR  
          fastcgi-stream         DIR  
          idb-connector          DIR  
          itoolkit               DIR  
          node-addon-api         DIR  
          node-fastcgi           DIR     
       package.json           STMF 
       package-lock.json      STMF 
       README.md              STMF 
    

    HTTP Server Folder

    /www/fastcgi

      conf                   DIR
         fastcgi.conf           STMF  
         httpd.conf             STMF     
      htdocs                 DIR
         index.html             STMF 
         index_bk.html          STMF  
      logs                   DIR
    

    /www/fastcgi/logs/error_zfcgi.Q8931649

    ************Beginning of data**************

    kill(-8931650, SIGUSR1) failed - [3] No such process

    ************End of Data********************

  42. mengxumx Account Deactivated

    Would you check the QCCSID of your system?

    dspsysval qccsid
    

    And ensure XMLSERVICE is installed.

    wrklib qxmlserv
    

    Seems the FastCGI server is running now but there are problems during retrieving the system values.

  43. mengxumx Account Deactivated

    To verify that XMLSERVICE is working, you can create a new js file (e.g. /home/iftikhar/node_fastcgi/test.js) inside the node_fastcgi folder.

    And copy one of the examples from → https://github.com/IBM/nodejs-itoolkit

    And run node /home/iftikhar/node_fastcgi/test.js to check if it can print the expected result.

  44. Iftikhar Ahmed

    ‌ Display System Value

    System value . . . . . : QCCSID Description . . . . . : Coded character set identifier

    Coded character set identifier . . . . . : 65535 1-65535

    wrklib qxmlserv

    Opt Library Attribute

      QXMLSERV    PROD     
    

    test.js code ( Example 2: Toolkit classes)

    var xt = require("itoolkit");
        var wk = require('itoolkit/lib/iwork');
        var nt = require('itoolkit/lib/inetwork');
    
        var conn = new xt.iConn("*LOCAL", "USERNAME", "PASSWORD");
    
        var work = new wk.iWork(conn);
        var net = new nt.iNetwork(conn);
    
        work.getSysValue("QCCSID", (output) => {
          console.log("QCCSID = " + output);
        });
    
        net.getTCPIPAttr((output) => {
          console.log(JSON.stringify(output, " ", 2));
        });
    

    node /home/iftikhar/node_fastcgi/test.js

    QCCSID = 65535

    {

    "TCP/IPv4_stack_status": "1",

    "How_long_active": "1142295",

    "When_last_started_-_date": "20190425",

    "When_last_started_-_time": "072532",

    "When_last_ended_-_date": "20190424",

    "When_last_ended_-_time": "202217",

    "Who_last_started_-_job_name": "DSP01",

    "Who_last_started_-_job_user_name": "TS6601",

    "Who_last_started_-_job_number": "991746",

    "Who_last_started_-_internal_job_identifier": "0",

    "Who_last_ended_-_job_name": "QTCPCTL",

    "Who_last_ended_-_job_user_name": "QSYS",

    "Who_last_ended_-_job_number": "116261",

    "Who_last_ended_-_internal_job_identifier": "0",

    "Offset_to_additional_information": "140",

    "Length_of_additional_information": "652",

    "Limited_mode": "0",

    "Offset_to_list_of_Internet_addresses": "752",

    "Number_of_Internet_addresses": "2",

    "Entry_length_for_list_of_Internet_addresses": "20",

    "DNS_protocol": "1",

    "Retries": "2",

    "Time_interval": "2",

    "Search_order": "1",

    "Initial_domain_name_server": "1",

    "DNS_listening_port": "53",

    "Host_name": "HBLPRD",

    "Domain_name": "HBL.COM",

    "Reserved": "",

    "Domain_search_list": "*DFT"

    }

  45. mengxumx Account Deactivated

    Would you replace the word QCCSID in the Example 2: Toolkit classes with QDATETIME ?

        work.getSysValue("QDATETIME", (output) => {
          console.log("QDATETIME= " + output);
        });
    
  46. Iftikhar Ahmed

    What would be the CCSID of index.html and dspsysval.js in my case it is 13488 and 819 respectively.

  47. mengxumx Account Deactivated

    It depends on the CCSID of system. Mine is 37 (English).

    As for the CCSID of index.html and dspsysval.js, it does not matter.

    IBM i default CCSID 65535 problem

    IBM i default system setting is CCSID 65535, also known as *HEX or no convert, can be one of your greatest barriers to successful IBM i modernization. Simply stated, CCSID 65535 does not work well with IBM i PASE ASCII environment, PHP, Java, Ruby, etc, therefore IBM i administrator action is required (see actions below).

    DSPSYSVAL SYSVAL(QCCSID)
     Coded character set
       identifier . . . . . :   65535      1-65535
    

    IBM i administrator actions CCSID 65535

    1. Best solution change system wide CCSID
      CHGSYSVAL SYSVAL(QCCSID) VALUE(37) Note: 37 is example, use appropriate CCSID, anything better than 65535
    2. Change CCSID Apache web applications (will not fix command line)
      Example is PHP, but applies to any web server. /www/zendsvr/conf/httpd.conf <-- (ILE Apache side) DefaultFsCCSID 37 CGIJobCCSID 37 Note: 37 is example, use appropriate CCSID, anything better than 65535 /www/zendsvr/conf/fastcgi.conf <-- (PASE side, SETENV each application line) CCSID=819 and LANG=C -- or -- CCSID=1208 and LANG=C Note: This file must be ASCII 819, be careful EDTF
    3. Change CCSID user profile for DB2 connect, scripts, etc.
      CHGUSRPRF USRPRF(IAM37) CCSID(37) Note: 37 is example, use appropriate CCSID, anything better than 65535
    4. Change CCSID specific job (not recommended)
      CHGJOB JOB(836270/MYID/MYJOB) CCSID(37) Note: 37 is example, use appropriate CCSID, anything better than 65535

    Questions?

    • Why is CCSID 65535 rough on PASE?
      PASE is an ASCII environment. ILE is an EBCDIC environment. DB2 tables are 99% EBCDIC. Data flowing between PASE and ILE or DB2, must be converted for anything to work (always). IBM i default CCSID 65535, also known as *HEX or no convert, completely shuts off IBM i natural conversions in DB2, shells, etc., and, nothing works.
    • Inconsistent symptoms of IBM i CCSID 65535?
      Many people experience general chaos understanding ‘PASE failures’. PASE applications work, other PASE applications fail. PASE applications work in one environment and fail in another environment. Worse, unfortunately, individual IBM i applications / products have taken on CCSID 6535 problem inconsistently (works in client access, not work in PHP, etc.). A long story of CCSID 65535 woe, but have faith, 99 out of 100 times, when everything is going wrong with your PASE application(s), XMLSERVICE, PHP, Java, Ruby, Node.js, etc, real issue is default setting CCSID 65535 (*HEX).
  48. Jesse G

    Closing as this is a request for assistance with nontrivial complexity. If you wish to pursue this further, I'd recommend professional services from one of our partners. Please contact jgorzins@us.ibm.com to discuss your options if interested.

  49. Log in to comment