This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Error

vaibhavds wrote on 2015-10-26:
Hello Team,


I am getting this error once while generating pdf, could you please explain about it.

Fatal error: Uncaught [503] Simultaneous API calls from a single IP are not allowed. thrown in /var/www/clients/client2/web20/web/report/pdfcrowd.phpon line 454

Thanks
support wrote on 2015-10-26:
If your application sends multiple API requests at a time, the service returns the 503 error. We rate limit the API to ensure fair distribution of capacity among users. You can learn more about the limitations here: <https://pdfcrowd.com/api/html-to-pdf-api/#api-ref-limitations>

If the API returns the 503 error, it is perfectly ok to sleep() for a few seconds and then resend the unsuccessful request. Here is an outline:
tries = 0
  success = False
  while not success:
     tries += 1
     try:
        call the API
        success = True
     catch (pdfcrowd.Error why):
         if tries == 5:
            some serious error, log or re-throw the exception
         else:
            sleep(1 or 2 seconds)


The effectiveness of this solution depends on how many users will request a PDF at the same time but in our experience this works reasonably well in most cases.