The HTTP 502 error is thrown when more than 100 HTTP(s) calls are made using Java-backed-Webscript API to read documents from the document library.
The code works fine if there are less number of documents. But when a large number of documents exist in the document library (meaning, hundreds of HTTP calls are made), it throws 502 error.
I have attempted by giving a sleep (e.g., sleep for 5 seconds) after a certain number of HTTP calls (say after 25 calls), but I still see 502 error. I have attempted with a longer time to sleep (longer than 5 seconds), and after a smaller number of document calls (say 5 seconds sleep after 2 documents), but I still get 502 error when a large number of documents exist in the document library, and the system is "flooded" with hundreds of HTTP calls.
I am using Java-backed-webscript API only and do not plan to change it to any other API.
The code extends from org.springframework.extensions.webscripts.AbstractWebScript, and I override the method execute(WebScriptRequest request, WebScriptResponse response)
Inside the execute method, I use the NodeService API, and it recursively iterates through the folders under the document library to get the document information (document/PDF and metadata of the document).
It is a GET HTTP(S) call.
Everything works fine if there are a less number of documents under the document library (say less than 100). But when there are more than 100 documents, the system cannot seem to handle being flooded with hundreds of HTTPS-GEt calls. Again, with sleep, it still throws the 502 exception.
I 502 exception is also thrown from the Spring API (which I do not manage/control) of org.springframework.extensions.webscripts.AbstractWebScript.
The exception received is:
IOException: Server returned HTTP response code: 502 for URL (simlar to): https://mydomain.org/alfresco/service/extract/abc
My questions:
1. Anything that you may suggest at the code level so that I can continue using the Java-backed-Webscript API for hundreds of HTTP calls? As you can see, the 502 error is thrown by Spring's AbstractWebScript, and I cannot put a try-catch to re-try.
2. Any configuration that you can suggest in the Alfresco server so that it will allow this? This code (amp file) is deployed directly in a single Alfresco server and the code (driver code) is also executed from inside the same server only, where the amp is deployed.