Skip to content

Websockets

Websockets are web protocols that allow clients and servers to communicate bi-directionally in realtime over a persistent TCP connection. All messages sent across a WebSocket connection are asynchronous.

Websockets

Async call via websockets

  • Take the code from the appendix and create two files in the same directory:
    • getMemWS.html
    • c.js

Websocket code

Within the HTML code, it takes user input, opens a handle to the kxw_qr_gw service and executes the .mon.getMemWS analytic with the input parameters.

  • In getMemWS.html, change the host and port tailored to your environment. The port should be addressing a running kxw_qr_gw process.
ws = new WebSocket("ws://HOST:PORT/");
  • Open the getMemWS.html on a browser.

  • Right-click > Inspect > Console. If a connection is successfully made, these should be printed to your console:

Screenshot

  • Change the parameter values and hit submit. Results should be returned as a table on screen.

Screenshot

Back to top