Home Applications WebSocketIRIS.js

WebSocketIRIS.js

InterSystems does not provide technical support for this project. Please contact its developer for the technical assistance.
5
1 reviews
0
Awards
298
Views
0
IPM installs
6
3
Details
Releases (7)
Reviews (1)
Issues
using IRIS Native API for Node.js

What's new in this version

  • get REDME and content of Repo in sync
  • operation verified

Docker Support added

This is now the version compatible to IRIS using IRIS Native API for Node.js
which is significantly different from the interface availaible for Caché.

Node / JavaScript have wide reputation to work as WebSocket client.
By using the IRIS adapter it becomes easy to control and to consume the results as a
Client for WebSocket Servers and to collect the replies in IRIS.

I used node-v10.15.1-x64.msi and intersystems-iris-native package

How it works

You provide a Global for input in namespace USER (default)

set ^ZSocketIn(0)=6
set ^ZSocketIn(1)=“Hello”
set ^ZSocketIn(2)=“World !”
set ^ZSocketIn(3)=“Robert”
set ^ZSocketIn(4)=“is waiting”
set ^ZSocketIn(5)=“for replies”
set ^ZSocketIn(6)=“exit”

The server is controlled by ^ZSocketRun from IRIS

set ^ZSocketRun(0)=“wss://ws.postman-echo.com/raw” ;echo server
set ^ZSocketRun=1 ; => send to echo server
; -1 => stop server and exit
; 0 => wait for action

and from echo server you get back a Global as output
written by Node.js using the Native API for Node.js

zwrite ^ZSocketOut   
^ZSocketOut="wss://ws.postman-echo.com/"    
^ZSocketOut(0)=6   
^ZSocketOut(1)="Hello"   
^ZSocketOut(2)="World !"    
^ZSocketOut(3)="Robert"     
^ZSocketOut(4)="is waiting"     
^ZSocketOut(5)="for replies"     
^ZSocketOut(6)="exit"    

Or run

USER>do ^ZSocket

Local installation and operation

The WebSocket Service is started from OS command line.
You can follow the progress in console output

C:\Program Files\nodejs\cache>node WebSocketIRIS.js <server-ip>:<superserver-port>     

image

Comment in DC

Docker support

Prerequisites

Make sure you have git and Docker desktop installed.

Installation

Clone/git pull the repo into any local directory

  git clone https://github.com/rcemper/WebSocketIRIS.js.git   

Open the terminal in this directory, build and run the container:

 docker-compose up -d   

Next open a IRIS session in namespace USER and prepare the Globals for testing
a test program ZSocket.MAC is in subdirectory src of download directory

Now activate your Node.js client
Have the external IP address and the SuperServerPort ready !
default: localhost:1972 is just a placeholder

docker-compose exec wsock nodejs WebSocketIRIS.js <ip-adr>:<port>  

From IRIS terminal run

USER>do ^ZSocket

*** Welcome to WebSocket Micoservice demo ***
Known Hosts (*=Exit) [1]:
1 wss://ws.postman-echo.com/raw
2 --- server 2 ----
3 --- server 3 ----
select (1): 1 ==> wss://ws.postman-echo.com/raw

Enter text to get echoed from WebSocketClient Service
Terminate with * at first position
or get generated text by %
or append new text with @

Made with
Version
2.0.124 Oct, 2024
Category
Technology Example
Works with
InterSystems IRIS
First published
16 Jul, 2020
Last edited
24 Oct, 2024
Last checked by moderator
31 Jan, 2025Doesn't work