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

openAppSession does not indicate "attach" vs "create" #84

Open OliverHenrichs opened 1 month ago

OliverHenrichs commented 1 month ago

Hi folks,

I use openAppSession to initiate new sessions and attach to existing ones on Qlik virtual proxies.

When I call e.g. session.getDoc(), the attached onWebSocketEvent function always logs the "opened" eventType. This happens regardless of the session actually attaching or creating, probably because the Websocket actually gets opened.

How can I discriminate what is happening? Can you e.g. expose the used session ID? If it is the one that I give in openAppSession, then I know it attached. If not, I know I have used up a new session.

This is kind of important, because there is a session limit of 5 in Qlik.

Cheers Oliver

nilzona commented 1 month ago

Hey Oliver. When using sessions at Qlik a rule of thumb is:

Same User on the Same App with the Same Identity Parameter = Same Session (= same websocket). When using openAppSession from @qlik/api we will always try to reuse the session if there is one.

We could expose a session id, but I'd like to understand a little bit more about the circumstances that makes you feel that you need it?

OliverHenrichs commented 4 weeks ago

Hi,

we develop a writeback extension. Our backend triggers an app-reload on users saving their changes. So far we let the sa_engine user trigger that reload.

If a customer's setup is multi-node and includes load-balancing in their virtual proxies, sa_engine user will ignore that. That's bad, so we now use the user's session, which enables us to find the correct target node for the reload. But if - for whatever reason - we're not attaching to but instead create a new session, we reduce the user's ability to open Qlik in another browser / on another device...

So as a first step we at least want to know what is happening in order to decide what to do.