Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"context deadline exceeded" with consecutive requests #577

Closed
NiklasBr opened this issue Nov 18, 2022 · 6 comments
Closed

"context deadline exceeded" with consecutive requests #577

NiklasBr opened this issue Nov 18, 2022 · 6 comments
Labels
bug Something isn't working libreoffice pdf-engines

Comments

@NiklasBr
Copy link

NiklasBr commented Nov 18, 2022

  gotenberg:
      image: gotenberg/gotenberg:7.7
      ports:
          - "3000:3000"
      command: [
          gotenberg,
          --chromium-ignore-certificate-errors=true,
          --chromium-disable-web-security,
          --uno-listener-restart-threshold=0
      ]

With the following code:

$partialDocuments = [];
foreach ($document->getAllChildren() as $child) {
    $html = $document->renderDocument($params);
    $request = Gotenberg::chromium($this->baseUri)->html(
        Stream::string($child->getPdfFileName() . '--transient.html', $html)
    );
    $partialDocuments[] = Gotenberg::save($request, SYSTEM_TEMP_DIRECTORY . DIRECTORY_SEPARATOR);
    sleep(2);
}

Next step is to merge the separate PDF:s but cannot reach it because the third $child crashes Gotenberg.

2022-11-18 15:00:31 {"level":"info","ts":1668780031.5957,"logger":"api","msg":"request handled","trace":"2f01838c-53b2-4d19-a0ad-b005cd94b324","remote_ip":"172.18.0.10","host":"gotenberg:3000","uri":"/forms/chromium/convert/html","method":"POST","path":"/forms/chromium/convert/html","referer":"","user_agent":"Symfony HttpClient/Curl","status":200,"latency":2557421751,"latency_human":"2.557421751s","bytes_in":4011,"bytes_out":18070}
2022-11-18 15:00:47 {"level":"info","ts":1668780047.2433655,"logger":"api","msg":"request handled","trace":"4e0f0f1c-f587-4756-ae79-eccc3da6b5bb","remote_ip":"172.18.0.10","host":"gotenberg:3000","uri":"/forms/chromium/convert/html","method":"POST","path":"/forms/chromium/convert/html","referer":"","user_agent":"Symfony HttpClient/Curl","status":200,"latency":2398633335,"latency_human":"2.398633335s","bytes_in":8009,"bytes_out":18448}
2022-11-18 15:01:28 {"level":"error","ts":1668780088.1366816,"logger":"api","msg":"convert HTML to PDF: convert to PDF: chromium PDF: wait for events: wait for event networkIdle: context deadline exceeded","trace":"bf54e5fc-ad6b-4f28-b8ca-f6f41f2e3386","remote_ip":"172.18.0.10","host":"gotenberg:3000","uri":"/forms/chromium/convert/html","method":"POST","path":"/forms/chromium/convert/html","referer":"","user_agent":"Symfony HttpClient/Curl","status":503,"latency":30012295722,"latency_human":"30.012295722s","bytes_in":11648,"bytes_out":19}

The PHP exception is:

"Gotenberg\Exceptions\GotenbergApiErroed: Service Unavailable in vendor/gotenberg/gotenberg-php/src/Exceptions/GotenbergApiErroed.php:16
Stack trace:
#0 vendor/gotenberg/gotenberg-php/src/Gotenberg.php(55): Gotenberg\Exceptions\GotenbergApiErroed::createFromResponse(Object(GuzzleHttp\Psr7\Response))
gotenberg/gotenberg-php#1 vendor/gotenberg/gotenberg-php/src/Gotenberg.php(71): Gotenberg\Gotenberg::send(Object(GuzzleHttp\Psr7\Request), Object(Symfony\Component\HttpClient\Psr18Client))
gotenberg/gotenberg-php#2 GotenbergPhp.php(182): Gotenberg\Gotenberg::save(Object(GuzzleHttp\Psr7\Request), '/var/www/...')
gotenberg/gotenberg#394 GotenbergPhp->buildPdf(Object(\Document\Printpage), Object(stdClass))
gotenberg/gotenberg-php#4 Processor.php(130): Web2Print\Processor\GotenbergPhp->buildPdf(Object("
@gulien
Copy link
Collaborator

gulien commented Dec 9, 2022

Hello @NiklasBr,

Sorry for the delay. It looks like your request timed out and your best option is either to increase the time out duration with --api-timeout or give your instance more CPU/memory.

@NiklasBr
Copy link
Author

It has the full 10 core 32GB RAM of the machine available, and it did not seem to be using a lot anyway.

@gulien gulien transferred this issue from gotenberg/gotenberg-php Jan 6, 2023
@vidklopcic
Copy link

I can also confirm that this happens with version 7.8.0 on a machine with more than enough resources. If I use 7.4.2 it works normally.

NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
A Docker-powered stateless API for PDF files.
Version: 7.8.0
-------------------------------------------------------
[SYSTEM] modules: api chromium gc libreoffice logging pdfcpu pdfengines pdftk prometheus qpdf uno uno-pdfengine webhook 
[SYSTEM] prometheus: collecting metrics
[SYSTEM] gc: application started
[SYSTEM] uno: long-running LibreOffice listener ready to start
[SYSTEM] pdfengines: pdfcpu pdftk qpdf uno-pdfengine
[SYSTEM] api: server listening on port 3000
{"level":"error","ts":1674551185.839853,"logger":"api","msg":"convert to PDF: lock long-running LibreOffice listener: start long-running LibreOffice listener: execute LibreOffice listener: context done: context deadline exceeded","trace":"6eef1be1-7f0f-48f6-b5ad-f349b5ae7e52","remote_ip":"172.40.13.4","host":"gotenberg:3000","uri":"/forms/libreoffice/convert","method":"POST","path":"/forms/libreoffice/convert","referer":"","user_agent":"python-requests/2.28.2","status":503,"latency":10001830810,"latency_human":"10.00183081s","bytes_in":14665,"bytes_out":19}

@stale
Copy link

stale bot commented Mar 25, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 25, 2023
@NiklasBr
Copy link
Author

I don't know what else I can contribute with in this issue. Could never resolve it on my own.

@stale stale bot removed the wontfix This will not be worked on label Mar 25, 2023
@gulien gulien added bug Something isn't working pdf-engines libreoffice labels Mar 25, 2023
@gulien
Copy link
Collaborator

gulien commented Nov 23, 2023

Closing this for now. Feel free to reopen this issue if it happens with the latest version.

@gulien gulien closed this as completed Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libreoffice pdf-engines
Projects
None yet
Development

No branches or pull requests

3 participants