Search code examples
reactjswebsocketqliksense

ReactJS Failed to construct 'WebSocket': The subprotocol '[object Object]' is invalid


I'm getting the following error in my react application using enigma.js (https://qlik.dev/apis/javascript/enigmajs) . I'm trying to initialize a WebSocket connection and im getting the error. "Failed to construct 'WebSocket': The subprotocol '[object Object]' is invalid".

The WebSocket connection URL is correct as it can be tested with https://catwalk.core.qlik.com/?engine_url=wss://sense-demo.qlik.com/app/133dab5d-8f56-4d40-b3e0-a6b401391bde which returns the data. You can try by editing the URL which will return an error.

the code is

async init() {
    
const appId = "133dab5d-8f56-4d40-b3e0-a6b401391bde";
    const url =
      "wss://sense-demo.qlik.com/app/133dab5d-8f56-4d40-b3e0-a6b401391bde"; 

    const session = enigma.create({
      schema,
      createSocket: () =>
        new WebSocket(url, {
        }),
    });

    const global = await session.open();
    const app = await global.openDoc(appId);
    const appLayout = await app.getAppLayout();

    console.log(appLayout);

  }

Solution

  • The solution is explained here

    https://github.com/qlik-oss/enigma.js/issues/889