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

PdfDataAsync timeout in IIS #2657

Open
yuxiang970813 opened this issue Jun 10, 2024 · 6 comments
Open

PdfDataAsync timeout in IIS #2657

yuxiang970813 opened this issue Jun 10, 2024 · 6 comments

Comments

@yuxiang970813
Copy link

Hi, my project's print function has been running smoothly for the past few weeks and no code updates have been made, but since May 27th it is suddenly not working properly. When the print button is pressed, PdfDataAsync gets stuck until it times out.
I have tried upgrading to the latest version (18.0.1) or downgrading to other versions of PuppeteerSharp to no avail, and I have noticed that PdfDataAsync works when debugging in Visual Studio, but gets stuck if publishing to IIS.
I also created a new project and published to another server and it still happens.

  • PuppeteerSharp version: 17.0.0
  • NET version: .NET Core 8.0.

Here is the code of the printing function:

BrowserFetcher browserFetcher = new();
await browserFetcher.DownloadAsync();
await using IBrowser browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true, });
await using IPage page = await browser.NewPageAsync();
await page.SetViewportAsync(new ViewPortOptions { Width = 794, Height = 1123 });
await page.GoToAsync(Security.DecodeBase64(url));

byte[] pdfStream = await page.PdfDataAsync();

return File(pdfStream, "application/pdf");

And here is the error message get from event viewer:

System.TimeoutException: Timeout of 180000 ms exceeded
   at PuppeteerSharp.Helpers.TaskHelper.WithTimeout[T](Task`1 task, TimeSpan timeout, Func`2 exceptionFactory) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Helpers/TaskHelper.cs:line 185
   at PuppeteerSharp.Cdp.CdpCDPSession.SendAsync(String method, Object args, Boolean waitForCallback, CommandOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/CdpCDPSession.cs:line 112
   at PuppeteerSharp.CDPSession.SendAsync[T](String method, Object args, CommandOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/CDPSession.cs:line 44
   at PuppeteerSharp.Cdp.CdpPage.PdfInternalAsync(String file, PdfOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/CdpPage.cs:line 829
   at PuppeteerSharp.Page.PdfAsync(String file, PdfOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Page.cs:line 382
   at ltis2023.Controllers.PrintingController.Pdf(String url, Boolean isPortrait)
@kjenova
Copy link

kjenova commented Jun 10, 2024

Hi,
I had the same problem and I fixed it by moving to PuppeteerExtraSharp, which works out of the box in my case.

The base PuppeteerSharp package would need an extra package to work in IIS, but that package isn't compatible with the last version of it:

https://stackoverflow.com/a/62429184/2373249
#2219

@yuxiang970813
Copy link
Author

Hi, I had the same problem and I fixed it by moving to PuppeteerExtraSharp, which works out of the box in my case.

The base PuppeteerSharp package would need an extra package to work in IIS, but that package isn't compatible with the last version of it:

https://stackoverflow.com/a/62429184/2373249 #2219

Thanks kjenova, the PuppeteerExtraSharp works for me! But I would like to know why puppeteer-sharp does not support this feature now?

@kblok
Copy link
Member

kblok commented Jun 16, 2024

Thank you for the report. I'm on vacation right now. I'll take a look at it on Monday!

@rogerfar
Copy link

rogerfar commented Jul 1, 2024

Thanks @kjenova, I ran into the same issue.

But it only stopped working when I upgraded to Puppeteer 18, it worked fine in 17.

@kblok
Copy link
Member

kblok commented Jul 3, 2024

Hi, I had the same problem and I fixed it by moving to PuppeteerExtraSharp, which works out of the box in my case.

The base PuppeteerSharp package would need an extra package to work in IIS, but that package isn't compatible with the last version of it:

https://stackoverflow.com/a/62429184/2373249 #2219

I bet that PuppeteerExtraSharp works because the last version is one year old, and it must be using an old Chrome version.

@kblok
Copy link
Member

kblok commented Jul 3, 2024

I would recommend using the Chromium browser till this issue is solved in Chrome for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants