RobWunderlich / qcb-qlik-sse

Implementation of qlik-sse that provides for functions as plugins
27 stars 12 forks source link

Measure State - Error:Error: App already open #15

Open rvaheldendaten opened 3 years ago

rvaheldendaten commented 3 years ago

Hi Rob!

We are running Qlik Sense Feb 2021.

We quite often get the MeasureState "Error:Error: App already open". Anyidea why this happens? See screenshot. We have not really found a pattern when we see this error.

image

Is this related to the max number of sessions the Qlik Sense User can have to open apps?

Thx, Roland

RobWunderlich commented 3 years ago

I think this may be caused by either the app being open for the same user in another context or a previous sse function not closing the app. Can you post the sse script you are using?

rvaheldendaten commented 3 years ago

hi Rob!

We do some work to generate our Master Items, but then we basically do a resident load. See below.

CreatorMeasures:
    Load *,
    QCB.CreateMeasure(MeasureMEASURE_NAME, MeasureDEFINITION_FORMULA,MeasureDesc , MeasureMASTER_ITEM_TAGS, MeasureLabel) as MeasureState
    ;
    LOAD 
      %MEASUREID,
      %MEASUREID as MeasureID,
      MeasureMEASURE_NAME,
      //add KPI number format if available
      if(Len(trim(FormatFunction))> 0, FormatFunction&'(')&
        MeasureDEFINITION_FORMULA& 
      if(Len(trim(FormatFunction))> 0, ','&chr(36)&'(='&chr(36)&'(vF('&%MEASUREID  & ')))'&')' ) as MeasureDEFINITION_FORMULA,

      MeasureMASTER_ITEM_TAGS,
       '='&chr(36)&'(vTMeasureDesc('&chr(39)&DESCRIPTION&chr(39)&'))' as MeasureDesc,
       '='&chr(36)&'(vTMeasure('&chr(39)&LABEL_DEFINITION&chr(39)&'))' & if (len(LABEL_DYN) > 0,'&chr(32)&'&LABEL_DYN)  as MeasureLabel
    resident QCB_Measure;

RobWunderlich commented 3 years ago

Are there any errors displayed on the sse console prior to the "App already open" error?

rvaheldendaten commented 3 years ago

We are running the SSE as "Windows Service". Where do I see the console output? I haven't found any logfile. Do I have to pipe the output to some file?

Thx, Roland

RobWunderlich commented 3 years ago

Take a look at the doc for whatever package you are using to run this as a service, to see how to pipe the stdout output.

rvaheldendaten commented 3 years ago

I'm using https://nssm.cc/ --> I will take a look how to retrieve the logs, and will come back to you next week.

Thx Roland

rvaheldendaten commented 3 years ago

Hello Rob!

I don't get much information in the logfiles. See attachment. logs.zip

I only see an error from enigma.js:

{ Error: App already open at Intercept.errorResponseInterceptor (D:\QVDs\07_SSE\qcb-qlik-sse-master_heldendaten\qcb-qlik-sse-master\node_modules\enigma.js\enigma.js:2668:19) at process._tickCallback (internal/process/next_tick.js:68:7) code: 1002, parameter: 'ecba5c14-b348-4bc7-b3ad-bc5c129672bd' }

So I guess for some reason Qlik Sense "thinks" the app is already open.

I'm running the QCB Windows Service as "Local System". Should I run it with the Qlik Sense service user? The user running the Qlik Sense script is a different user anyway - maybe this causes some trouble.

Unfortunately I was not able to reproduce it while I was on site. So it seems it's not a general problem.

Best regards, Roland

rvaheldendaten commented 3 years ago

hi! We recently saw this issue again. Anyone else having this issue?

The error disappears when we duplicate the app. Then the next (manual) reload creates the masteritems again.

We are running QlikSense May 2021 Patch1.

rvaheldendaten commented 2 years ago

I guess we now know what's happening:

If two "QCB"-tasks (for example via Qlik Sense Scheduler) run in parallel it seems QlikSession.js does not handle parallel connections correctly. It seems instead of creating a second session for the second app, we get a "SESSION_ATTACHED" in the trace log. When "SESSION_ATTACHED" happens, we get a "App Already Open" Error.

We are currently testing to create a seperate enigma websocket connection for every masteritems. I will post some code, once we have tested it in more detail.

image

RobWunderlich commented 2 years ago

QlikSession.js was written to cache and reuse the session to avoid the problem of exceeding the 5 session limit per license in QSEoW. I see how that design could be a problem with parallel activity. I recommend you test any new design with repeated runs as well.

rvaheldendaten commented 2 years ago

I read somewhere that this 5 session limitation only exists when you go via Qlik Sense Proxy. But I'm not quite sure.

Basically what we want to try:

1) suspendOnClose: false, 2) Open the websocket with a new /identity/ for each call 3) Close the session immediately

I guess this is probably a litte bit slower, as we do a new session for each call. But hopefully we can avoid the current issue. We will do some days of testing and then come back to you!

rvaheldendaten commented 2 years ago

hi! We have now testet the code for some weeks and it seems more stable: in QlikSession.js I now do a seperate identity for each app:

const config = { schema, url: isDesktop ? 'ws://localhost:9076/app/engineData' : 'wss://localhost:4747/app/engineData' +'/identity/'+commonHeader.appId, suspendOnClose: true, }

RobWunderlich commented 2 years ago

It sounds like an improvement. Please submit a PR we you are ready.

Himans2 commented 1 year ago

Hi,

The "Error: App already open" message can occur in Qlik Sense when multiple users try to access and modify the same app simultaneously. When one user opens an app, the app is locked for editing until the user closes it. If another user tries to open and edit the same app while it is locked, they will receive the "Error: App already open" message.

To avoid this issue, you can implement a few best practices for app sharing and collaboration in Qlik Sense:

You can Limit app access to a smaller group of users who need to edit or view the app, rather than allowing it to be accessed by a large number of users simultaneously.

Make sure all users are aware of the app lock mechanism and the importance of closing the app after editing to release the lock.

Set up a notification system or workflow to inform users when an app is available for editing, so that they can avoid attempting to open the app at the same time.

Consider using Qlik Sense's collaborative features, such as shared bookmarks or sheets, to allow multiple users to work on different aspects of the same app without conflicting with each other.

Thank you