selenium-standalone icon indicating copy to clipboard operation
selenium-standalone copied to clipboard

pkill java, Selenium Process Running

Open dtothefp opened this issue 11 years ago • 23 comments

@vvo I know this is going to be a somewhat vague question and you are a busy guy so answer it as you see fit. I work on a team and since upgrading from 4.4.3 other members of the team get the Error: Another Selenium process is already running error? I have no idea why it would not be happening on my machine vs. others. Do you have any ideas off the top of your head why this could be occurring is a seemingly random manner?

//install.js
import {assign} from 'lodash';
import selenium from 'selenium-standalone';

let config = {
  // check for more recent versions of selenium here:
  // http://selenium-release.storage.googleapis.com/index.html
  baseURL: 'http://selenium-release.storage.googleapis.com',
  drivers: {
    chrome: {
      // check for more recent versions of chrome driver here:
      // http://chromedriver.storage.googleapis.com/index.html
      version: '2.15',
      arch: process.arch,
      baseURL: 'http://chromedriver.storage.googleapis.com'
    },
    ie: {
      // check for more recent versions of internet explorer driver here:
      // http://selenium-release.storage.googleapis.com/index.html
      version: '2.45',
      arch: process.arch,
      baseURL: 'http://selenium-release.storage.googleapis.com'
    }
  },
  logger(message) {
    console.log(message);
  }
};

export default function(opts, cb) {
  if (typeof opts === 'function') {
    cb = opts;
    opts = {};
  }
  assign(config, opts);
  selenium.install(config, cb);
}

//run-selenium.js

const SELENIUM_VERSION = '2.47.0';

const installOpts = {
  version: SELENIUM_VERSION
};

const spawnOpts = {
  version: SELENIUM_VERSION,
  spawnOptions: {
    stdio: 'ignore'
  }
};

install(installOpts, () => {
  selenium.start(spawnOpts, (err, child) => {
    if (err) {
      throw new PluginError({
        plugin: '[selenium]',
        message: `${err.message} => pkill java`
      });
    }

    const cp = runWebdriver(baseConfig, 'local');
    closeCp(cp, (code) => {
      child.kill(code);
    });
  });
});

dtothefp avatar Oct 02 '15 16:10 dtothefp

Are you sure the child.kill(code) line runs? That's the crucial part.

silvenon avatar Oct 02 '15 16:10 silvenon

@silvenon the error is coming on the user first running the install/start after fresh install of selenium-standalone. I will double check with my coworkers to ensure that code runs but this error does not occur with selenium-standalone 4.4.3 and I don't think that would effect the child.kill(code)

dtothefp avatar Oct 02 '15 17:10 dtothefp

Will have a try if I can reproduce the isuue, maube try to run the standardbselenium or if you are able to debug it the code is pretty straightforward. Just checking the real args passed to selenium may be enough to try them with a standard selenium server.

Maybe the stdin/out ignore is the issue here

vvo avatar Oct 02 '15 23:10 vvo

@dtothefp Can you setup a test repository where I have only to npm install and then follow your instructions on how to have it fail/success (based on the selenium-standalone version)

vvo avatar Oct 06 '15 09:10 vvo

Also if you can precisely test what are the failing/working version it would be good it will help a lot

vvo avatar Oct 06 '15 09:10 vvo

@vvo that is the tricky part because on my machine it is no problem with current version, although on co-workers it is breaking. I need to take the time and do what you suggested in checking the args passed to the child process on a machine where the problem is happening. If that doesn't work I can try to reproduce something for you but for now I'm at a loss because it's on a per machine basis. Could it somehow be affected by how JAVA was installed as that is the main thing that I could see varying between machines?

dtothefp avatar Oct 06 '15 15:10 dtothefp

Yes JAVA installation, OS, Node.js version, anything really.

But the message is really clear and is located inside the selenium-standalone code I believe so you should be able to track down the code.

You can clone the repository on a machine that is failing, then npm link then from the project that uses selenium-standalone you can npm link selenium-standalone and then debug from there.

vvo avatar Oct 06 '15 15:10 vvo

:+1: I am unsure if this is directly related, but it looks like the same issue. I am just straight using the CLI commands and running into the same error. There is not another Selenium service running.

JohnBaileyN avatar Oct 06 '15 17:10 JohnBaileyN

@JohnBaileyN Can you dig into the code and see why do you get the error message? Like I proposed in https://github.com/vvo/selenium-standalone/issues/139#issuecomment-145903062

Maybe you could also install versions and get the exact version where it started failing? That would help, thanks

vvo avatar Oct 06 '15 18:10 vvo

@vvo It turns out that the issue was due to "invalid or corrupt jarfile" and the error message from this project is just generic due to Exit 1 which can occur for this same reason. The cause of the error was Cisco's Anyconnect which my company uses. To resolve the issue

$ sudo /opt/cisco/anyconnect/bin/acwebsecagent -disablesvc -websecurity $ selenium-standalone install The callout is that the error message needs to be improved in this project. I can work with the authors and do a PR if anyone is interested.

In the meantime, I have a workaround that I'm going to include in our local machine setup or just use docker (e.g.)

JohnBaileyN avatar Oct 07 '15 05:10 JohnBaileyN

The callout is that the error message needs to be improved in this project. I can work with the authors and do a PR if anyone is interested.

YES! I am a lot interested in this because it came multiple times. It would be great let me know if you need anything.

vvo avatar Oct 07 '15 06:10 vvo

@vvo I'm budgeting some time this week to debug this issue on some of my co-workers machines so hopefully can find some info for you

dtothefp avatar Oct 13 '15 17:10 dtothefp

Coool nail it!

vvo avatar Oct 13 '15 18:10 vvo

@vvo have some updates for you. Issue seems related to users with Java version 1.6*. One of the users with the issue had

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)

I had a hard time logging the errors using

selenium.stderr.on('data', function (data) {
  console.log('grep stderr: ' + data);
});

//or 

selenium.on('error', function (err) {
  console.log(err);
});

so I replaced your spawn with exec

    exec(opts.javaPath + ' ' + args.join(' '),
      function (error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        console.log('stderr: ' + stderr);
        if (error !== null) {
          console.log('exec error: ' + error);
        }
    });

And got the following output, something about an "Unsupported major.minor version"

screen shot 2015-10-14 at 5 34 00 pm

From what I could tell we were experiencing this problem all the way back to selenium-standalone v4.5.3, but I can't guarantee the exact version where the bug for us was introduced. As I said v4.4.3 works for everyone on my team.

Not sure about the poor spawn error logging but seems like more robust checks for errors rather than the generic code = 1 error would be helpful along with pinpointing the issues we may be having with JAVA 1.6. When users upgraded to 1.8 the problem was solved.

dtothefp avatar Oct 14 '15 21:10 dtothefp

@dtothefp I ran into this issue due to Cisco AnyConnect corrupting jars from certain sources. I planned on adding the handling to provide more information and not just "Already running" I won't be able to work on that until this weekend. If someone jumps on it before then, cool

Cheers!

JohnBaileyN avatar Oct 15 '15 00:10 JohnBaileyN

@JohnBaileyN I'd be happy to help out but couldn't quite figure out how to get more detailed errors through spawn?

dtothefp avatar Oct 15 '15 01:10 dtothefp

Maybe better to close the previous server when running a new one? I think you will mostly want to do that anyway.

silvenon avatar Oct 15 '15 09:10 silvenon

@silvenon I'm not sure what you mean....I don't think that is the issue we are running into here

dtothefp avatar Oct 15 '15 12:10 dtothefp

I thought the issue is that the Selenium server sometimes ends up running in the background, so you are unable to start a new one.

silvenon avatar Oct 15 '15 13:10 silvenon

I thought the issue is that the Selenium server sometimes ends up running in the background

This is the error message showing up but it's not the real issue it seems.

vvo avatar Oct 15 '15 19:10 vvo