Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

ckarras22
New Contributor III

Problem connecting to Engine API through Python or HTML

Hello,

Today i upgraded Qlik Sense desktop to the latest edition (3.1.4) after having my existing one expired. We have developed a series of internal tools based on Python that we need to test them as a POC against desktop edition, before we move them to Qlik Sense. We haven't test them against server though.

It is impossible to connect to Engine API through python and/or raw HTML code after the upgrade. Unfortunately i can't revert to the previous version.

A small sample that used to work is like that

>>>>>>>>>>>>>>>CODE START>>>>>>>>>>>>>>>>>>>>>>>>

from websocket import create_connection

import json

data=json.dumps({

                    'jsonrpc': '2.0',

                    'id': 0,

                    'method': 'OpenDoc',

                    'handle': -1,

                    'params': ['test.qvf']

                },

                    sort_keys=True,

                 indent=4,

                 separators=(',', ': '))

ws = create_connection("ws://localhost:4848")

print("Sending req...")

ws.send(data)

print("Sent")

print("Receiving...")

result =  ws.recv()

print("Received '%s'" % result)

#ws.close()


print("press enter")

<<<<<<<<<<<<<<<<<<<<CODE END<<<<<<<<<<<<<<

The exception is like that

exception.jpg

This same exception is raised also when i try to connect through HTML's websockets.

The code is tested in the corporate PC as well in my private one, just to confirm that a possible network issue stops the connection.

Thank you for your help

Chris K.

1 Solution

Accepted Solutions
Employee
Employee

Re: Problem connecting to Engine API through Python or HTML

Make sure you connect to ws://localhost:4848/app/

The /app/ part is there so the Broker service knows that it's the engine you are trying to talk to and not some other service

8 Replies
Employee
Employee

Re: Problem connecting to Engine API through Python or HTML

Make sure you connect to ws://localhost:4848/app/

The /app/ part is there so the Broker service knows that it's the engine you are trying to talk to and not some other service

ckarras22
New Contributor III

Re: Problem connecting to Engine API through Python or HTML

Alexander thank you so much...it worked!!! Though i don't understand why it was working all the time without the /app/ part. But in any case, your explanation is clear.

BR

Chris K.

Employee
Employee

Re: Problem connecting to Engine API through Python or HTML

Pre-3.0 we did not have the broker service so it was the engine service that listened to localhost:4848

However best practice has always been to use the /app/ route as that is also the session route you should use when opening applications.

Would be cool to see what you have built! Sadly we are lacking good python projects right now

ckarras22
New Contributor III

Re: Problem connecting to Engine API through Python or HTML

Yes ... this is my feeling, that the best practice of using the /app/ is forced now.

I will prepare a stripped down version of what can be done with python and Engine API, considering data models, connections, objects and children objects, manipulation of handlers etc and post as document here.

BR

Chris K.

cls
New Contributor II

Re: Problem connecting to Engine API through Python or HTML

Hi Chris,

Have you shared a document or have any code available for python / Engine API? I would appreciate it! I checked on your profile here on community as well as Branch and am not seeing anything posted yet.

Thanks,

Chris

ckarras22
New Contributor III

Re: Problem connecting to Engine API through Python or HTML

Hello Chris,

I haven't done something to strip down an example due to heavy workload on other projects. Nevertheless it is in my to do list to share.

BR

Chris K.

cls
New Contributor II

Re: Problem connecting to Engine API through Python or HTML

Great thanks, I have followed you. If you could put it on Branch that would be excellent. If you're not Branch Slack channel yet, I hope you sign up and perhaps ping me when you submit it. I can help you clean it up or advise on / facilitate the sharing if desired.

Best,

Chris

mayuringale25
New Contributor

Re: Problem connecting to Engine API through Python or HTML

Hii ,

 Can you share the code for connecting qlik engine api using python

Community Browser