hardkoded / puppeteer-sharp

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

upgrade PuppeteerSharp and HeadlessChromium.Puppeteer.Lambda.Dotnet #2807

Closed satviktechie1986 closed 4 days ago

satviktechie1986 commented 4 days ago

I have upgrade PuppeteerSharp and HeadlessChromium.Puppeteer.Lambda.Dotnet to generate pdf using aws lambda. but somehow i am running into an error : as below

PuppeteerSharp Version : 20.0.3

HeadlessChromium.Puppeteer.Lambda.Dotnet Version : 1.1.0.94

PuppeteerSharp.ProcessException: Failed to create connection ---> System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException (104): Connection reset by peer --- End of inner exception stack trace --- at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async) at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options) at System.Net.WebSockets.WebSocketHandle.ConnectAsync(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken, ClientWebSocketOptions options) at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore(Uri uri, HttpMessageInvoker invoker, CancellationToken cancellationToken) at PuppeteerSharp.Transport.WebSocketTransport.CreateDefaultWebSocket(Uri url, IConnectionOptions options, CancellationToken cancellationToken) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Transport/WebSocketTransport.cs:line 118 at PuppeteerSharp.Transport.WebSocketTransport.CreateDefaultTransport(Uri url, IConnectionOptions connectionOptions, CancellationToken cancellationToken) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Transport/WebSocketTransport.cs:line 125 at PuppeteerSharp.Cdp.Connection.Create(String url, IConnectionOptions connectionOptions, ILoggerFactory loggerFactory, CancellationToken cancellationToken) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/Connection.cs:line 151

Code :

                var chromeLocation = new ChromiumExtractor(new LoggerFactory().AddSerilog(Log.Logger)).ExtractChromium();

                var launchOptions = new LaunchOptions()
                {
                    ExecutablePath = chromeLocation,
                    Args = DefaultChromeArgs,
                    Headless = true,
                    Timeout = 0
                };

// var browserLauncher = new HeadlessChromiumPuppeteerLauncher(new LoggerFactory().AddSerilog(Log.Logger)); await using (var browser = await new Launcher(new LoggerFactory().AddSerilog(Log.Logger)).LaunchAsync(launchOptions)) { await using var page = await browser.NewPageAsync(); await page.GoToAsync("http://www.google.com"); await page.EvaluateExpressionHandleAsync("document.fonts.ready"); context.Logger.LogInformation("EvaluateExpressionHandleAsync "); var result = await page.PdfStreamAsync(); var fileTransferUtility = new TransferUtility(S3Client); await fileTransferUtility.UploadAsync(result, report.BucketName, s3ObjectKey); }

Dotnet Version : 8

Azure Pipeline Steps :

trigger: branches: include:

kblok commented 4 days ago

Duplicated of https://github.com/hardkoded/puppeteer-sharp/issues/2785