qlik-oss / qlik-api-ts

Typescript types and Javascript library for consuming Qlik API's
https://qlik.dev
ISC License
8 stars 3 forks source link

QlikSense Desktop connection #64

Closed OliverHenrichs closed 3 weeks ago

OliverHenrichs commented 4 weeks ago

Hi,

I am using openAppSession to successfully connect to QlikSense Server. Is it also possible to open a session to QlikSense Desktop (without ssl)?

Example Code:

this.session = await openAppSession({ 
    appId: "C:/users/someDirectoryBecauseQSDesktop",  
    hostConfig: {
        host: "127.0.0.1:4848" ,
        authType: "none", // No idea what to put here
    }
});  
this.session.onWebSocketEvent(this.sessionEventCallback);  
this.document = await this.session.getDoc();

I want .getDoc to not crash with

    write EPROTO B44A0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:c:\\ws\\deps\\openssl\\openssl\\ssl\\record\\ssl3_record.c:355:\n

on url

   wss://127.0.0.1:4848/app/C:/Users/OliverHenrichs/Documents/Qlik/Sense/Apps/MyApp.qvf?reloadUri=wss%3A%2F%2F127.0.0.1%3A4848%2Fsense%2Fapp%2FC%3A%5CUsers%5COliverHenrichs%5CDocuments%5CQlik%5CSense%5CApps%5CMyApp.qvf

One can see that wss:// is prepended to the host - which is wrong, it should be ws://.

I tried prepending ws:// to the host (the docs somewhere say that the url only defaults to https if no scheme is given), but wss:// was still prepended (resulting in wss://ws://...).

How should I configure the session? Is there an authType for Desktop? Is this even the right place?

Best regards Oliver

OliverHenrichs commented 3 weeks ago

Ok, I found the solution.

It was to simply start the url with either http:// or https:// instead of ws:// or wss://.

The library code then replaces http with ws in function toValidWebsocketLocationUrl. So the following hostconfig works with QSDesktop:

{
    host: "http://127.0.0.1",
    authType: "none",
}

I guess I became confused because I migrated code that had used enigma.js. Therein, we always had to use the ws:// and wss:// prefixes when creating the Websockets for the Qlik sessions.

As a suggestion, one could improve toValidWebsocketLocationUrl to also handle the ws(s):// scheme.

Lastly, for some reason http://localhost does not work.

nilzona commented 3 weeks ago

Thank you for coming back and let us know about your solution.

It's a good suggestion! We will try to look into that.