I'm working on AWS Lambda with Go lang. I'm deploying Go lang code, use chromedp , with Docker image and got websocket URL timeout reached error. My lambda setting is with 3008 MB RAM memory, 512MB storage, and 15 minutes timeout. Can you find what is wrong and how to fix this? Here is file main.go
and Dockerfile
File main.go
(chromedp part)
func getPage(URL string, lineNum string, stationNm string) {
// settings for crawling
ctx, cancle := chromedp.NewContext(
context.Background(),
chromedp.WithLogf(log.Printf),
)
defer cancle()
opts := []chromedp.ExecAllocatorOption{
chromedp.DisableGPU,
chromedp.NoSandbox,
chromedp.Headless,
chromedp.Flag("no-zygote", true),
chromedp.Flag("single-process", true),
chromedp.Flag("homedir", "/tmp"),
chromedp.Flag("data-path", "/tmp/data-path"),
chromedp.Flag("disk-cache-dir", "/tmp/cache-dir"),
chromedp.Flag("remote-debugging-port", "9222"),
chromedp.Flag("remote-debugging-address", "0.0.0.0"),
chromedp.Flag("disable-dev-shm-usage", true),
}
allocCtx, cancel := chromedp.NewExecAllocator(ctx, opts...)
defer cancel()
ctx, cancel = chromedp.NewContext(allocCtx, chromedp.WithLogf(log.Printf))
defer cancel()
var htmlContent string
ch := chromedp.WaitNewTarget(ctx, func(i *target.Info) bool {
return strings.Contains(i.URL, "/timetable/web/")
})
}
File Dockerfile
FROM public.ecr.aws/lambda/provided:al2 AS build
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64
# Get rid of the extension warning
RUN mkdir -p /opt/extensions
RUN yum -y install golang
RUN go env -w GOPROXY=direct
# Clone git, copying go.mod, go.sum, main.go
WORKDIR /var/task/
RUN yum install git -y
RUN git clone https://github.com/seedspirit/NaverCrawler-CICD-go.git
RUN cp NaverCrawler-CICD-go/main.go /var/task/
RUN cp NaverCrawler-CICD-go/go.mod /var/task/
RUN cp NaverCrawler-CICD-go/go.sum /var/task/
# cache dependencies
RUN go mod download
RUN go build -o main .
FROM public.ecr.aws/lambda/provided:al2
COPY --from=build /var/task/main /var/task/main
# Install Chrome dependencies
RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm -o chrome.rpm && \
yum install -y ./chrome.rpm && \
yum install -y fontconfig libX11 GConf2 dbus-x11
ENTRYPOINT ["/var/task/main"]