Initializing help system before first use

Creating the Web Socket Connection

Create a websocket

To create a web socket, point a web socket client at:

ws://[server]/insightservices/ws/v1/compute/messages
For secure web sockets, use the following:
wss://[server]/insightservices/ws/v1/compute/messages 

You must supply the bearer token for the authorization header when opening the socket. For information on generating the bearer token using the REST API, see Generate the Bearer Token.

The response will include the header connection-id to indicate the id of the socket. The connection-id is an important value to retain. Each job submission must include this header to associate the job and its progress events with the web socket.

For example, using node's web socket library ( https://www.npmjs.com/ )
const WebSocket = require('ws');
this.webSocket = new WebSocket(wsAddress, {
    perMessageDeflate: true, //enables message compression
    headers: {
        authorization: 'Bearer ${this._token}'. //token generated from clientId and secret
    }
});

ws.on('message', function incoming(data) {
  let message = JSON.parse(data);
  
  if (message.messageType == "JOB_STATUS_UPDATED") {
     //then do something with the status
  } else if (message.messageType == "RUNLOG_UPDATED") {
    //then print the runlog
  } else ….
});
This will initialize the web socket handshake.
Important The response will set the header connection-id to indicate the id of the socket. This connection id must be added as the id parameter in the submitted job when you are using a web socket to connect to Xpress Insight 5.

Keep Alive Ping

The server will periodically issue ping messages to ensure the client is still alive. The client should respond with a pong message echoing back the contents of the ping. If no pong is received after a five-minute period, the socket is classed as idle and will be disconnected.

Bearer Token Refresh

The client needs to send a message of type UPDATE_TOKEN before the configured (default 15 minutes) expiry time of the bearer token. If this message is not sent before the current token expires then the socket will be disconnected on token expiry.
{
    "messageType": "UPDATE_TOKEN" 
    "messagePayload": {
       "token": "<token_associated_with_the_socket>" 
    }
}

Reconnecting a Socket

If the socket connection is dropped, the client should create a new socket, see the previous section Create a websocket.
ws://[server]/insightservices/ws/v1/compute/messages
It is not possible to reconnect to the same socket.