Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
gregory_longe
New Contributor III

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
Employee
Employee

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

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.

9 Replies
Employee
Employee

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

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.

Employee
Employee

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

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

gregory_longe
New Contributor III

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

Alexander,

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

Much appreciated,

Gregory

Employee
Employee

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

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.

gregory_longe
New Contributor III

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

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

Employee
Employee

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

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

gregory_longe
New Contributor III

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

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

Employee
Employee

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

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

gregory_longe
New Contributor III

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

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

Community Browser