3.12 React app websocket-service failures flood DevConsole

:leaves: LEAF version:3.12

:jigsaw: LEAF component(s): react-app

Issue/Question: I have recently upgraded my react application to the new Kubernetes backed service registry. In my chrome dev-tools the console log is filled with these:

Configuration:

const k8services = window.ENV?.CONFIGURED_SERVERS || {};

environment.js

window.ENV.CONFIGURED_SERVERS = {
  'ui-support-service.default': {
    annotations: {
      'data-service.leidos-leaf.com/event-service-uri':
        'ws://websocket-service/web-socket/event-query',
      'leaf-tools.leidos-leaf.com/live-metadata-editing': 'true',
      'leaf-tools.leidos-leaf.com/non-live-metadata-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-viewing': 'false',
      'service.leidos-leaf.com/base-uri':
        'http://localhost/ui-support-service/rest',
    },
    available: true,
    capabilities: ['Data Store'],
    endpoints: {
      oasEndpointJson: '/app/openapi.json',
      oasEndpointYaml: '/app/openapi.yaml',
    },
    name: 'ui-support-service',
    namespace: 'default',
    serviceKey: 'ui-support-service.default',
  },
  'tspi-ds.launch-to-orbit': {
    annotations: {
      'data-service.leidos-leaf.com/event-service-uri':
        'ws://websocket-service/web-socket/event-query',
      'leaf-tools.leidos-leaf.com/live-metadata-editing': 'true',
      'leaf-tools.leidos-leaf.com/non-live-metadata-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-viewing': 'false',
      'service.leidos-leaf.com/base-uri': 'http://localhost/tspi-ds/rest',
    },
    available: true,
    capabilities: ['Data Store'],
    endpoints: {
      oasEndpointJson: '/app/openapi.json',
      oasEndpointYaml: '/app/openapi.yaml',
    },
    name: 'tspi-ds',
    namespace: 'launch-to-orbit',
    serviceKey: 'tspi-ds.launch-to-orbit',
  },
};

React SR Component:

<RegisteredServiceProvider
              interval={null}
              serviceRegistryPath="state-vector-staging-ds.roo-oor/rest"
              user={DEFAULT_USER}
              defaultService="ui-support-service"
              preRequest={preRequest}
              configuredServices={k8services}
              requireSelectedService
            >

My project uses a websocket-service, which I thought was a standard pre-LEAF 3.12 configuration. Here’s my get all pods.

I was wondering if there are others out there with this same issue?

Thank you LEAF.
sg

Hi!

I believe that your configured servers are missing two additional configurations. Namely, restPath and socketPath. restPath tells your app where to reach out to talk to a data-service and the socketPath tells the app where to make a websocket connection. Using your environment.js as an example, setting those configurations for each configured server should look like this:

// environment.js
window.ENV.CONFIGURED_SERVERS = {
  'ui-support-service.default': {
    restPath: '/ui-support-service/rest',
    socketPath: '/websocket-service/web-socket/event-query',
    ... //using ellipsis to omit the rest of the configs
  },
  'tspi-ds.launch-to-orbit': {
    restPath: '/tspi-ds/rest',
    socketPath: '/websocket-service/web-socket/event-query`,
    ... //using ellipsis to omit the rest of the configs
  }
}

No luck with the additions. The log messages occur two errors at a time and seem to start out fast, every 5 seconds, and then begin to throttle back to every 15 seconds.

What are the annotations for anyway, I never got any documentation about this type of data-service configuration, meaning services that are REST based. Could the annotation be the problem?

sg

I added them like this:

window.ENV.CONFIGURED_SERVERS = {
  'ui-support-service.default': {
    annotations: {
      'data-service.leidos-leaf.com/event-service-uri':
        'ws://websocket-service/web-socket/event-query',
      'leaf-tools.leidos-leaf.com/live-metadata-editing': 'true',
      'leaf-tools.leidos-leaf.com/non-live-metadata-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-viewing': 'false',
      'service.leidos-leaf.com/base-uri':
        'http://localhost/ui-support-service/rest',
    },
    available: true,
    capabilities: ['Data Store'],
    endpoints: {
      oasEndpointJson: '/app/openapi.json',
      oasEndpointYaml: '/app/openapi.yaml',
    },
    name: 'ui-support-service',
    namespace: 'default',
    serviceKey: 'ui-support-service.default',
    restPath: '/ui-support-service/rest',
    socketPath: 'ws://websocket-service/web-socket/event-query',
  },
  'tspi-ds.launch-to-orbit': {
    annotations: {
      'data-service.leidos-leaf.com/event-service-uri':
        'ws://websocket-service/web-socket/event-query',
      'leaf-tools.leidos-leaf.com/live-metadata-editing': 'true',
      'leaf-tools.leidos-leaf.com/non-live-metadata-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-editing': 'false',
      'leaf-tools.leidos-leaf.com/rule-viewing': 'false',
      'service.leidos-leaf.com/base-uri': 'http://localhost/tspi-ds/rest',
    },
    available: true,
    capabilities: ['Data Store'],
    endpoints: {
      oasEndpointJson: '/app/openapi.json',
      oasEndpointYaml: '/app/openapi.yaml',
    },
    name: 'tspi-ds',
    namespace: 'launch-to-orbit',
    serviceKey: 'tspi-ds.launch-to-orbit',
    restPath: '/tspi-ds/rest',
    socketPath: 'ws://websocket-service/web-socket/event-query',
  },
};