Qlik Community

Ask a Question

Integration, Extension & APIs

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

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
GustavLindstrom
Contributor
Contributor

Max Parallel Sessions Exceeded qlik engine api

I'm running a python script to extract the script code from Qlik Sense apps through the Engine json API. After a few runs I get error Max Parallel Sessions Exceeded. I create a new web socket for every app (seams to be the only way to open a new app) and the sessions don't seam to end when I close the Web socket. Any help would be appreciated.

 

def get_scripts(app_ids, header_user):
count = 0
app_scripts = []
for app_id in app_ids:
ws = websocket.create_connection("wss://localhost/jwt/app/{}".format(app_id), sslopt={"cert_reqs": ssl.CERT_NONE}, header=header_user)
call_id = 0
ws.send(json.dumps({
"method": "OpenDoc",
"handle": -1,
"params": [
"{}".format(app_id)
],
"outKey": -1,
"id": 2
}))
while call_id < 2:
result = ws.recv()
y = json.loads(result)
try:
call_id = y["id"]
except:
print("")

ws.send(json.dumps({
"handle": 1,
"method": "GetScript",
"params": {},
"outKey": -1,
"id": 3
}))

while call_id < 3:
result = ws.recv()
y = json.loads(result)
print(y)
#print(y)
try:
call_id = y["id"]
except:
print("")
if call_id == 3:
result = y['result']
script = result['qScript']
print(app_id)
print(call_id)
print(script[0:100])
app_scripts.append([app_id, script])
count = count + 1
ws.close()

return app_scripts

 

2 Solutions

Accepted Solutions
Damien_Villaret
Support
Support

Hello @GustavLindstrom 

For non core-based licenses, there is a session limit of 5 sessions max per 5 minutes.
Even if you close the session, you won't be able to start a new one before 5 minutes.

What you need to do in your script is fetch the session cookie you get back from Qlik Sense on your first request and then reuse this session cookie to reuse the same session for subsequent requests.

View solution in original post

Damien_Villaret
Support
Support

Hello @GustavLindstrom 

Yes, that's what you get as response headers on your first request, then you should pass it in the request headers on the second request, I believe this should be the syntax:

{'Cookie': 'X-Qlik-Session-jwt=35cd253e-9e76-4cb2-a42e-75f0ed20c160;}

It's similar to this enigma.js example
https://community.qlik.com/t5/Knowledge-Base/Qlik-Sense-Repository-API-Engine-API-Enigma-js-example-...

View solution in original post

3 Replies
Damien_Villaret
Support
Support

Hello @GustavLindstrom 

For non core-based licenses, there is a session limit of 5 sessions max per 5 minutes.
Even if you close the session, you won't be able to start a new one before 5 minutes.

What you need to do in your script is fetch the session cookie you get back from Qlik Sense on your first request and then reuse this session cookie to reuse the same session for subsequent requests.

View solution in original post

GustavLindstrom
Contributor
Contributor
Author

Hi Damien thanks for replying

If I print 

print(ws.headers)

I get this 

{'set-cookie': 'X-Qlik-Session-jwt=35cd253e-9e76-4cb2-a42e-75f0ed20c160; Path=/; HttpOnly; SameSite=Lax; Secure',

Should I put  X-Qlik-Session-jwt 35cd253e-9e76-4cb2-a42e-75f0ed20c160 in the header for the next websocket.create_connection? How should the header for the next connection look like?

Best regards 

Gustav

Damien_Villaret
Support
Support

Hello @GustavLindstrom 

Yes, that's what you get as response headers on your first request, then you should pass it in the request headers on the second request, I believe this should be the syntax:

{'Cookie': 'X-Qlik-Session-jwt=35cd253e-9e76-4cb2-a42e-75f0ed20c160;}

It's similar to this enigma.js example
https://community.qlik.com/t5/Knowledge-Base/Qlik-Sense-Repository-API-Engine-API-Enigma-js-example-...

View solution in original post