Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
GustavLindstrom
Contributor II
Contributor II

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.

If the issue is solved please mark the answer with Accept as Solution.

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

If the issue is solved please mark the answer with Accept as Solution.

View solution in original post

4 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.

If the issue is solved please mark the answer with Accept as Solution.
GustavLindstrom
Contributor II
Contributor II
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-...

If the issue is solved please mark the answer with Accept as Solution.
fabdulazeez
Partner - Creator III
Partner - Creator III

Hi Damien,

When establishing a direct connection to the engine using the following configuration:

WebSocket Secure connection to: wss://<Server>:4747/app/<AppId>

Certificates configuration:

certs = ({"ca_certs": ca, "certfile": cer, "keyfile": key, "cert_reqs":ssl.CERT_REQUIRED,"server_side": False})

User specified as sa_api with the following header:

header = {'X-Qlik-User: UserDirectory=internal; UserId=sa_api'}

 

Is there a limitation on the number of connections that can be opened same time parallely ?