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]/api/compute-job-messages
For secure web sockets, use the following:
wss://[server]]/api/compute-job-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
        Accept: ‘application/vnd.com.fico.xpress.insight.v2+json’
    }
});

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.

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]/api/compute-job-messages
It is not possible to reconnect to the same socket.

© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.