Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Engine API and qsocks: updated title not shown in Sense app

Hey all,

I used qsocks as a wrapper for the Engine API in a Qlik Sense extension in order to update the title property of an object in my Qlik Sense application on demand. Basically, I linked the following code to an HTML button:

Knipsel.PNG

The code seems to do its job just fine: the obj.getProperties method returns an object with the updated title. This change is however not reflected in the Qlik Sense application itself. When I try to refresh the Qlik Sense application, I get eternally the loading screen with the bubbles. If I however close the application, I am able to reopen it through the hub and the new title is suddenly shown.

Am I overlooking something in my approach? How do I get the updated title immediately reflected in the application without the need for the procedure above or even without the need for the user to explicitely reload the page? If I follow the same steps with the Engine API Explorer, the change is immediately reflected in the app.

Thanks in advance

1 Solution

Accepted Solutions
Alexander_Thor
Employee
Employee

Hey Gregory,

This is due to what we call Engine Sessions in Qlik. When you connect via qsocks without a config object it will connect to ws://localhost:4848/app/transient for a global connection.

However, when you open a application within desktop it will open a session to ws://localhost:4848/app/<url encoded path to file>. So, now you have two connections but to two different engine sessions but for the same app, that's why you are not seeing your changes reflected.

So, if you want to see your changes immediately then URL encode the file path to the app and specify it as qsocks.Connect({appname: <url encoded path>}) and it will connect to the same socket/session.

Now, if you call openDoc in that session you will most likely get a error saying "App already open" since, well it is.
So instead use the method getActiveDoc() to get a handle to the opened document within the engine session.

View solution in original post

9 Replies
Alexander_Thor
Employee
Employee

Hey Gregory,

This is due to what we call Engine Sessions in Qlik. When you connect via qsocks without a config object it will connect to ws://localhost:4848/app/transient for a global connection.

However, when you open a application within desktop it will open a session to ws://localhost:4848/app/<url encoded path to file>. So, now you have two connections but to two different engine sessions but for the same app, that's why you are not seeing your changes reflected.

So, if you want to see your changes immediately then URL encode the file path to the app and specify it as qsocks.Connect({appname: <url encoded path>}) and it will connect to the same socket/session.

Now, if you call openDoc in that session you will most likely get a error saying "App already open" since, well it is.
So instead use the method getActiveDoc() to get a handle to the opened document within the engine session.

Alexander_Thor
Employee
Employee

Btw if you are in a es2015 world then something like
encodeURIComponent(String.raw`C:\Users\akl\Documents\Qlik\Sense\Apps\BoundingBoxes.qvf`)

will get you the raw string and you don't have to match single backslashes to un-escape them

Anonymous
Not applicable
Author

Alexander,

Thank you for your help! It works perfectly and I've learned something new

Much appreciated,

Gregory

Alexander_Thor
Employee
Employee

Yes it's a little counter intuitive that we use the app name in the socket url but it's used by the Qlik Sense Proxy to make sure we route you to a engine instance that actually have the app present on that node.

Anonymous
Not applicable
Author

Alexander,

Just a small question regarding the migration of this code to a Qlik Sense server. Will the title change only affect the session of the user who triggered the change or all users? (I currently have no access to our server, otherwise I would test it myself...)

Thanks in advance,

Gregory

Alexander_Thor
Employee
Employee

By default on a server you are not allowed to make changes to core assets within a published app so there would not be multiple users accessing the app.

However you could opt to connect directly to QIX, bypassing the proxy, using certificate authentication which would grant you full access to edit an app. Those changes should be reflected to all connected users, I haven't tested it personally but in theory it should

Anonymous
Not applicable
Author

Alexander,

So I managed to install the extension on our Qlik Sense server and using the softpatch parameter, the object titles are correctly altered for the user's session. I've tested this however by opening the access portal on the server itself via a remote desktop connection.

Now, when I test the extension via the conventional way: typing the server address in a browser window and authenticating, the extension no long works. The web socket cannot be opened, the handshake is cancelled. What is the difference in connecting to the Qlik Engine via this approach compared to opening the access portal on the server itself and how to handle the difference in the config object used in qsocks?

The current config object looks like this:

var config = {

  host: 'xx.xx.com',

  isSecure: true,

  appname: 'd5fb1650-9fc9-4e6e-802a-1153d2857832

};

Thanks in advance,

Gregory

Alexander_Thor
Employee
Employee

That sounds strange. Config.host value corresponds to the same URL as you are browsing to?
It's nothing strange going in, under the hood it will essentially call new WebSocket('wss://servername/app/<app guid>') which is the same as the qlik client uses

Anonymous
Not applicable
Author

I don't understand it myself. The next day, I tried again with the same setup and suddenly it worked fine...