Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
krmvacar
Creator II

HTTP protocol error 500

Hi ,

I have an nprinting trigger application in Qliksense app and this application gives this error once a week: Error: HTTP protocol error 500 (Internal Server Error). I couldn't find the reason, I would be very happy if you could help me.


20240925T072007.786+0300 Error: HTTP protocol error 500 (Internal Server Error):
20240925T072007.786+0300
20240925T072007.786+0300 An unhandled exception occurred; check the log for more information.
20240925T072007.788+0300 Execution Failed
20240925T072007.798+0300 Execution finished.

Versions:

Qliksense May 2024

Nprinting Feb2024 SR2

Best Regards 

@Frank_S @Lech_Miszkiewicz ,@Ruggero_Piccoli

Labels (2)
1 Solution

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP

Hi @krmvacar 

Answering above points:

point 2 - Checking timeout. I suggest to increase to value between 30-300 if necessary

  • Lech_Miszkiewicz_0-1727262133502.png

     

point 4 - Whitelisting In NPrinting: Admin --> Settings --> OnDemand all possible combinations of Qlik Sense server addresses

point 5 - absolutely, should be added as per point 4. Then in connection POST Method configuration you would have: 

ADDITIONAL REQUEST PARAMETERS
Query parameters Leave blank
Query headers:
Name: Origin
Value: 'https://your trusted qliksense origin declared in NPrinting'
 
point 7 - what service account. I normally use NPrinting service account (which in my case is always different than QS service account)
point 8 - I always use different service account for Qlik Sense and different service account for NPrinting. I had already very heated conversation regarding this with Qlik Support as I saw issues where the same account was used to run both services. They were not confirming what is best supported configration but: https://help.qlik.com/en-US/nprinting/February2024/Content/NPrinting/DeployingQVNprinting/User-accou...
 
Lastly:
If I was running your code I would do following change to include POST connection before every post method:

 

for i=1 to FieldValueCount('TASKID')

LIB CONNECT TO 'REST_Nprinting_POST;

let vPublshTaskURL = 'https://*********/api/v1/tasks/'&FieldValue('TASKID',$(i))&'/executions';

SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");

Sleep(30000);

next

 
 cheers
cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

10 Replies
Lech_Miszkiewicz
Partner Ambassador/MVP

Hi @krmvacar, I will be more than happy to help, but...

What is the script you are executing? I wrote whole library (NPrinting.qvs) and I handle connection and authentication almost each time I trigger API call https://nprintingadventures.com/2019/04/08/nprinting-api-qlik-rest-subroutines/ .

In this case we dont know what you are trying to do, how you have configured your GET and POST connections, what user you are using, how you handle cookies, how often you trigger your API calls, how busy is your server (Qlik Sense and NPrinting) etc... We just know that you got an error when trying to connect to NPrinting.

I will say - I am not getting such error, so there is something in your script or environment what is configured differently. What is it? We need more info from you to be able to help. 

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
krmvacar
Creator II
Author

Hi @Lech_Miszkiewicz ,

Thank you for reply,

Of course I can give more information.

For login NP

***********************************************************************

LIB CONNECT TO 'REST_Nprinting_GET ;

RestConnectorMasterTable:
SQL SELECT
"Set-Cookie",
"__KEY__response_header"
FROM JSON "_response_header" PK "__KEY__response_header";

[_response_header]:
LOAD [Set-Cookie] AS [Set-Cookie]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY__response_header]);


Let vCookieRaw = Peek('Set-Cookie',0,'cookie_items');
Let vCookie = TextBetween(vCookieRaw,'SameSite=None,',' Path=/',SubStringCount(vCookieRaw,'SameSite=None')-1);
DROP TABLE RestConnectorMasterTable;

*******************************************************************************

POST method

TASKID:
load * inline [
TASKID
1900693b-6d89-4eb1-bd19-b8ee6d22c0c2 
5fc70910-2ase-49af-b3b5-efa4c30a5fd2 
8f5b1d2b-7afd-4c6d-9ef3-7c9838fb743e ];

 

for i=1 to FieldValueCount('TASKID')

let vPublshTaskURL = 'https://*********/api/v1/tasks/'&FieldValue('TASKID',$(i))&'/executions';

SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");

Sleep(30000);

next

************************************************************************************************************

Task runs on qliksense every morning at 7am

 

Thank you so much

 

 

 

Lech_Miszkiewicz
Partner Ambassador/MVP

Hi @krmvacar 

In short you are using:

  • GET method
    • to get a cookie 
  • "POST method" - although I dont see connection (Lib Connection POST) !!! - to run:
    • run 1st task & wait 30 seconds 
    • run 2nd task & wait 30 seconds
    • run 3rd task & wait 30 seconds

Questions:

  1. At which stage do you get an error? Is this during the GET method or POST method (which attempt)?
  2. What are the timeout settings on your connections?
  3. What are the workoads on the servers at that time - is it possible that there are many things reloading/running /executing and there is not enough time to get response in time?
  4. Do you have your Origins whitelisted (IPs, Hostnames and FQDNs)?
  5. Do you specify Origins in your headers?
  6. Are you having both servers in the same regional settings?
  7. What account are you using to run this? 
  8. Do you have dedicated different service accounts for Qlik Sense and NPrinting services?

Having a full load log with error (you can scramble hostnames or domainnames if need be) would be helpful.

cheers

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
krmvacar
Creator II
Author

Hi @Lech_Miszkiewicz 

I forgot to add the post method connection link

1- Post method.

2-I don't know how to check this?

3- yes it is possible the server is fine

4- Qliksense proxy whitelist? for nprinting ıp no 

5-Yes, I specified it, but the qliksense address I connect to is not available in the origin, should I add it?

6- yes

7- service accaount

8 - same account

 

Lech_Miszkiewicz
Partner Ambassador/MVP

Hi @krmvacar 

Answering above points:

point 2 - Checking timeout. I suggest to increase to value between 30-300 if necessary

  • Lech_Miszkiewicz_0-1727262133502.png

     

point 4 - Whitelisting In NPrinting: Admin --> Settings --> OnDemand all possible combinations of Qlik Sense server addresses

point 5 - absolutely, should be added as per point 4. Then in connection POST Method configuration you would have: 

ADDITIONAL REQUEST PARAMETERS
Query parameters Leave blank
Query headers:
Name: Origin
Value: 'https://your trusted qliksense origin declared in NPrinting'
 
point 7 - what service account. I normally use NPrinting service account (which in my case is always different than QS service account)
point 8 - I always use different service account for Qlik Sense and different service account for NPrinting. I had already very heated conversation regarding this with Qlik Support as I saw issues where the same account was used to run both services. They were not confirming what is best supported configration but: https://help.qlik.com/en-US/nprinting/February2024/Content/NPrinting/DeployingQVNprinting/User-accou...
 
Lastly:
If I was running your code I would do following change to include POST connection before every post method:

 

for i=1 to FieldValueCount('TASKID')

LIB CONNECT TO 'REST_Nprinting_POST;

let vPublshTaskURL = 'https://*********/api/v1/tasks/'&FieldValue('TASKID',$(i))&'/executions';

SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");

Sleep(30000);

next

 
 cheers
cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Anonymous
Not applicable

Hello, HTTP is a client-server protocol which works under a request-response model, in your case, I suppose you got the 500 error on your "client"; anyway, an HTTP's 500 error is a server side error.

If you are using a REST architecture, the body of the HTTP response status code (500) might have a more detailed error, if not, and if you have the permissions, you can debug the server application by taking a look into some error log; otherwise, and if you don't have permissions to the server application, you might want to contact the server admins as they might help you by reviewing their end (logs).

Finally, from my point of view sleep(30000) is not recomanded and you should use a a dynimic timer because if you have more than one application doing the same task you don't want all of them requesting resurces at exactly the same time.

krmvacar
Creator II
Author

Hi @Lech_Miszkiewicz ,

I made the change you said and updated the timeout period to 90. I also edited the code. I will continue testing, thank you very much for the information.

 

krmvacar
Creator II
Author

Hi @Lech_Miszkiewicz ,

It gave an error again but this time the reason is different.

A disabled task id was defined in the inline table, so it gave an error.

After giving task IDs in the inline table, can we check whether they are disabled or enabled?

If we add that control here and say that only the enabled ones should go, the possibility of an error will be eliminated.

Thank you very much for your help.

Lech_Miszkiewicz
Partner Ambassador/MVP

Hi @krmvacar 

Of course you can write control script checking if those tasks are enabled. I have part of it done and on screenshot I have flagged what field you can use to get this info from.

Have a looked at the NPrinting.qvs i mentioned in my previous post?: https://nprintingadventures.com/2019/04/08/nprinting-api-qlik-rest-subroutines/

There you will see field which will allow you to validate if task is enabled. This is in the section of script which loads tasks via API. Please have a look and apply according to your needs.

Lech_Miszkiewicz_0-1727333872341.png

 

Cheers 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.