aws / aws/aws-lambda-base-images
C# function runs in local docker container fails when deployed as lambda
- Dominant language
- No language data
- Stars
- 777
- Forks
- 118
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
Thank you for providing these base images.
I've created a custom image from public.ecr.aws/lambda/dotnet:core3.1.2021.06.02.11 for my lambda function.
My issue is that the function runs successfully on my local docker, but when its deployed to AWS lambda it fails.
The function simply creates a Chrome webdriver and tries to open a page. As mentioned it runs perfectly on my local docker (multiple continuous invocations), but when deployed as a Lambda, it fails with the following error:
```
[1623074722.885][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
```
Is there some sort of constraint in terms of opening ports etc, that is not present in the base image but is there in the AWS cloud container sandbox?
Docker version: v20.10.5
Platform: Windows 10
I have attached my full source code.
## Instructions
### Local run
Extract the zip
```
docker build .
docker run -p 9000:8080 lm-selenium
irm "http://localhost:9000/2015-03-31/functions/function/invocations" -Body '""' -Method Post
```
This will return "Google"
### AWS run
Now deploy the image into a new ECR repository (called my-repo for example):
```
(Get-ECRLoginCommand).Password | docker login --username AWS --password-stdin zzzzz.dkr.ecr.ap-southeast-2.amazonaws.com
docker tag lm-selenium:latest zzzzz.dkr.ecr.ap-southeast-2.amazonaws.com/my-repo:latest
docker push zzzzz..dkr.ecr.ap-southeast-2.amazonaws.com/my-repos:latest
```
Create a new lambda function from the image:

Run the lambda:
- Expected the lambda to return "Google"
- Instead the result is an error
```
8/06/2021 12:10:33 AM START RequestId: 8e22709f-c551-4ae7-86f3-eaaf037ddd88 Version: $LATEST... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM Setting up chrome options... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM Connection refused Connection refused... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM Starting ChromeDriver 91.0.4472.19 (1bf021f248676a0b2ab3ee0561d83a59e424c23e-refs/branch-heads/4472@{#288}) on port 42199... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM Only local connections are allowed.... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM [1623075033.627][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM Connection refused Connection refused... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM ChromeDriver was started successfully.... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM Connection refused Connection refused... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at lambda_method(Closure , Stream , Stream , LambdaContextInternal )... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at SeleniumTest.Function.FunctionHandler(String input, ILambdaContext context) in /source/base/Function.cs:line 21... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM (unknown error: DevToolsActivePort file doesn't exist)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM unknown error: Chrome failed to start: crashed.... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.): WebDriverException... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM REPORT RequestId: 8e22709f-c551-4ae7-86f3-eaaf037ddd88 Duration: 333.39 ms Billed Duration: 334 ms Memory Size: 1024 MB Max Memory Used: 308 MB ... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
8/06/2021 12:10:33 AM END RequestId: 8e22709f-c551-4ae7-86f3-eaaf037ddd88... 2021/06/07/[$LATEST]9b439c2125d3472f9fd51fa2526c467b
```
[lambda-selenium-docker.zip](https://github.com/aws/aws-lambda-base-images/files/6612826/lambda-selenium-docker.zip)
Why is the same error not occurring in the locally deployed container?
Thanks
Avner
Contributor guide
Assessment
This issue has not been assessed yet.