Home Applications WebSocketIRIS.js

WebSocketIRIS.js

This application is not supported by InterSystems Corporation. Please be notified that you use it at your own risk.
5
1 reviews
0
Awards
212
Views
0
IPM installs
5
3
Details
Releases
Reviews
Issues
Pull requests
using IRIS Native API for Node.js

What's new in this version

Adjust public echo server and README

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 ^ZSockIn(0)=6
set ^ZSockIn(1)=“Hello”
set ^ZSockIn(2)=“World !”
set ^ZSockIn(3)=“Robert”
set ^ZSockIn(4)=“is waiting”
set ^ZSockIn(5)=“for replies”
set ^ZSockIn(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 ^ZSockOut
^ZSocketOut=“wss://ws.postman-echo.com/”
^ZZSockOut(0)=6
^ZSockOut(1)=“Hello”
^ZSockOut(2)=“World !”
^ZSockOut(3)=“Robert”
^ZSockOut(4)=“is waiting”
^ZSockOut(5)=“for replies”
^ZSockOut(6)=“exit”

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

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

image

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 :

image

Read more
Made with
Version
2.0.005 Jul, 2023
ObjectScript quality test
Category
Technology Example
Works with
InterSystems IRIS
First published
16 Jul, 2020
Last checked by moderator
27 Jun, 2023Works