You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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<System.Int32>.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);
}
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<System.Int32>.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 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:
- refs/heads/lambda
resources:
repositories:
type: git
ref: refs/heads/lambda
jobs:
displayName: Agent job 1
pool:
vmImage: ubuntu-latest
steps:
displayName: NuGet Authenticate
inputs:
forceReinstallCredentialProvider: true
displayName: dotnet restore
inputs:
command: restore
projects: PIB.DocumentGeneration/PIB.DocumentGeneration.csproj
feedRestore: d80f8f22-ac95-4ca4-aefb-24ca67302a57
displayName: dotnet publish
inputs:
command: publish
publishWebProjects: false
projects: PIB.DocumentGeneration/PIB.DocumentGeneration.csproj
arguments: --configuration
zipAfterPublish: false
modifyOutputPath: false
displayName: 'Publish Artifact: drop'
displayName: Archive $(Build.ArtifactStagingDirectory)/dist/release/app/
inputs:
rootFolderOrFile: $(Build.ArtifactStagingDirectory)/dist/release/app/
includeRootFolder: false
archiveFile: $(Build.ArtifactStagingDirectory)/dist/release/test.zip
displayName: 'S3 Upload: optis-pipeline'
inputs:
awsCredentials: 7d33f0c0-8c2d-4058-862d-76bf06d51e82-123
regionName: eu-west-2
bucketName: optis-pipeline
sourceFolder: $(Build.ArtifactStagingDirectory)/dist/release
globExpressions: test.zip
targetFolder: DEV/
filesAcl: bucket-owner-read
createBucket: true
displayName: 'AWS CLI: lambda'
inputs:
awsCredentials: 7d33f0c0-8c2d-4058-862d-76bf06d51e82-123
regionName: eu-west-1
awsCommand: lambda
awsSubCommand: update-function-code
awsArguments: --function-name local-testdocument --s3-bucket test --s3-key DEV/test.zip
failOnStandardError: false
The text was updated successfully, but these errors were encountered: