Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: 'Too Many Files Open' after 1-2 hours of running #12741

Closed
EuclidHeron opened this issue Sep 14, 2023 · 9 comments
Closed

[🐛 Bug]: 'Too Many Files Open' after 1-2 hours of running #12741

EuclidHeron opened this issue Sep 14, 2023 · 9 comments

Comments

@EuclidHeron
Copy link

What happened?

Hi,

After Running Selenium for 2-3 hours I get:

2023-09-14T07:27:08.185-05:00	Caused by: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.185-05:00	Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver process to start.	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	Caused by: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	Caused by: java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	Caused by: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.199-05:00	java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.199-05:00	Caused by: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.199-05:00	Caused by: java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

How can we reproduce the issue?

I was running my my Selenium process with the following DockerFile for 2-3 hours. After that, the  issue starts appearing.


ARG CHROME_VERSION=115.0

# See https://hub.docker.com/r/selenium/standalone-chrome for Selenium standalone
# to fix a version, put '115.0' or such

# Stage 1: Pre-built Selenium Standalone Chrome image
FROM selenium/standalone-chrome:${CHROME_VERSION} as chrome

# Stage 2: Use Amazon Corretto as the base image, can also do 'FROM amazoncorretto:17' to get latest
FROM amazoncorretto:17.0.8-al2
# Currently using latest corretto; if need to fix a version then do amazoncorretto:17.0.8-al2

#https://stackoverflow.com/questions/45323271/how-to-run-selenium-with-chrome-in-docker
#https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-wsl-windows-subsystem-for-linux
# Install necessary dependencies to run chrome in headless mode
RUN yum install -y libX11 libXcomposite libXcursor libXdamage libXext libXi libXtst cups-libs libXScrnSaver libXrandr alsa-lib pango atk at-spi2-atk gtk3

# Copy Chrome and ChromeDriver from the first stage
COPY --from=chrome /usr/bin/chromedriver /usr/bin/chromedriver
COPY --from=chrome /opt/google/chrome/ /opt/google/chrome/

# Set environment variables for Chrome and ChromeDriver
ENV CHROME_BIN=/opt/google/chrome/google-chrome
ENV CHROMEDRIVER_BIN=/usr/bin/chromedriver

# In the original consulting file CHROMEDRIVER_PORT, CHROMEDRIVER_WHITELISTED_IPS, and CHROMEDRIVER_URL_BASE are not set
ENV CHROMEDRIVER_PORT 4444
ENV CHROMEDRIVER_WHITELISTED_IPS "127.0.0.1"
ENV CHROMEDRIVER_URL_BASE ''

# App Setup
EXPOSE 8080
EXPOSE 5005

# Copy application JAR into the image
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar

# Run application
ENTRYPOINT ["java","-jar", "-Xmx600m", "/app.jar"]


### Relevant log output

```shell
2023-09-14T07:27:08.185-05:00	Caused by: org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.185-05:00	Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver process to start.	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	Caused by: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	Caused by: java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.193-05:00	Caused by: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.199-05:00	java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.199-05:00	Caused by: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee

2023-09-14T07:27:08.199-05:00	Caused by: java.io.UncheckedIOException: java.io.IOException: Too many open files	ecs/my-app-container/546ee453bfd44bee88fed350f9d80bee


### Operating System

AWS Linux

### Selenium version

Java 17, selenium version 4.12.1

### What are the browser(s) and version(s) where you see this issue?

I am using chromedriver

### What are the browser driver(s) and version(s) where you see this issue?

I am using tandalone-chrome

### Are you using Selenium Grid?

No
@github-actions
Copy link

@EuclidHeron, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@EuclidHeron EuclidHeron changed the title [🐛 Bug]: 'Too Many Files Open' after [🐛 Bug]: 'Too Many Files Open' after 1-2 hours of running Sep 14, 2023
@joerg1985
Copy link
Member

I have perpared the code to replace the apache commons exec with the ProcessBuilder, this requires java 11. As soon as #11526 is done, i can crwate a PR for it, this might fix this issue.

@EuclidHeron
Copy link
Author

Thank you @joerg1985 !

@joerg1985
Copy link
Member

#12898 has been merged an this might have been fixed. @EuclidHeron please retest as soon as the next Selenium release is out.

@titusfortner
Copy link
Member

Actually, please try out the SNAPSHOT version tomorrow if you can.

Add this repo: https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/java/pom.xml#L18-L26
Set version to 4.15.0-SNAPSHOT

@EuclidHeron
Copy link
Author

Hi @titusfortner , happy to help. My dockerfile is:

ARG CHROME_VERSION=116.0
# See https://hub.docker.com/r/selenium/standalone-chrome for Selenium standalone
FROM selenium/standalone-chrome:${CHROME_VERSION} as chrome

Should I wait until 118.0 ? Or is there a different docker tag I can/should use?

@titusfortner
Copy link
Member

4.14.1 was released earlier today, which should have the fix in it.

@diemol
Copy link
Member

diemol commented Nov 24, 2023

We are currently on 4.15.0, and as the previous comment points out, this should have been fixed. We can reopen if this is still valid.

@diemol diemol closed this as completed Nov 24, 2023
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants