hardkoded / puppeteer-sharp

Headless Chrome .NET API
https://www.puppeteersharp.com
MIT License
3.42k stars 446 forks source link

Timeout of 180000 ms exceeded in the .net mvc #2774

Closed gan-gan0 closed 2 months ago

gan-gan0 commented 2 months ago

Hi kblok, I am using html to pdf via puppeteer-sharp, I am installed the version 20.0., but I get the timeout error, it is run on windows servers 2022. can you let me know how to fix it.

Timeout of 180000 ms exceeded Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TimeoutException: Timeout of 180000 ms exceeded

Stack Trace: [TimeoutException: Timeout of 180000 ms exceeded] PuppeteerSharp.Helpers.d12`1.MoveNext() in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Helpers/TaskHelper.cs:180 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 PuppeteerSharp.Cdp.d13.MoveNext() in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/CdpCDPSession.cs:112 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 PuppeteerSharp.d34`1.MoveNext() in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/CDPSession.cs:44 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 PuppeteerSharp.Cdp.d88.MoveNext() in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/CdpPage.cs:830 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +32 Test.Controllers.d__13.MoveNext() in D:\Test\Controllers\GenerateController.cs:723

the code as below: await new BrowserFetcher().DownloadAsync(); using (var browser = await Puppeteer.LaunchAsync(new LaunchOptions{Timeout = 60000,Headless = true})) { var page = await browser.NewPageAsync(); page.DefaultTimeout = 60000; page.DefaultNavigationTimeout = 60000; var pdfOptions = new PdfOptions { Format = PaperFormat.A4, PrintBackground = true, MarginOptions = new MarginOptions { Top = "20px", Right = "50px", Bottom = "100px", Left = "50px" }
}; await Task.Delay(3000); var stream=await page.PdfDataAsync(pdfOptions);// throw the error return File(stream.ToArray(), "application/pdf", fileName); }

kblok commented 2 months ago

This will help https://www.puppeteersharp.com/docs/IssuesGeneratingPdfFiles.html

gan-gan0 commented 2 months ago

Hi kblok, how to position the download path, I have found the setup.exe is under C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\dac3957d\78dbd505\assembly\dl3\ec0d9390\00553bf4_d1feda01\Chrome\Win64-128.0.6613.119\chrome-win64, but i run it, but I still get the same error.