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

Run Concurrently (using different ports?) #81

Open
Lordnibbler opened this issue Aug 14, 2016 · 5 comments
Open

Run Concurrently (using different ports?) #81

Lordnibbler opened this issue Aug 14, 2016 · 5 comments

Comments

@Lordnibbler
Copy link

Lordnibbler commented Aug 14, 2016

First off, thanks for the awesome gem.

I want to use headless to run concurrent selenium builds using this gem, and I see that xvfb should allow being passed an --auto-servernum flag at runtime. This will presumably prevent the following collision error I'm seeing currently when running concurrent builds:

Errno::ECONNREFUSED: Failed to open TCP connection to 127.0.0.1:7057 (Connection refused - connect(2) for "127.0.0.1" port 7057)

I've tried invoking headless using a random display each time inside a sidekiq worker with concurrency of 3, but I get similar errors

headless = Headless.new(display: rand(100))
headless.start
@leonid-shevtsov
Copy link
Owner

Does using Headless.new(autopick: true) in the sidekick worker solve your problem? That should choose the first available display number.

(BTW, the error is from Selenium, not Xvfb, and it means that Selenium failed to boot - this might be caused by missing Xvfb, but other things too - like a Selenium port conflict.)

@Lordnibbler
Copy link
Author

@leonid-shevtsov isn't autopick: true the default?

It would seem that passing display: key will conflict with the autopick settings.

I do have Xvfb installed, and do not have this error when running a single thread, only when I introduce concurrent workers.

@leonid-shevtsov
Copy link
Owner

How do you start your Selenium? Do you specify different ports for each Selenium instance?

@Lordnibbler
Copy link
Author

Lordnibbler commented Aug 18, 2016

@leonid-shevtsov simply like this:

def driver
  @driver ||= Selenium::WebDriver.for :firefox
end

should I be specifying a unique port each time if I am running on concurrent workers?

@zpetukhov
Copy link

zpetukhov commented Dec 4, 2016

@leonid-shevtsov @Lordnibbler
I can confirm that there is issue to run scripts which uses selenium+headless concurrently.
I've writed small script which reproduces that kind of error:
http://pastebin.com/96h2WEuf
To reproduce error:
run the script in two different consoles, first with command line parameter "10" (without quotes), second with command line parameter "1". Then see what's happening after second script finish.

Looks like using different display numbers solves this issue.
But I think in that case it's better to run Xvfb one time before starting ruby scripts, there is no need to start/stop Xvfb which is performed when you executing headless.start / headless.destroy (destroy also occurs on_exit automatically)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants