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

connect ECONNREFUSED after successfully connected #2301

Closed
defusioner opened this issue Sep 17, 2017 · 3 comments
Closed

connect ECONNREFUSED after successfully connected #2301

defusioner opened this issue Sep 17, 2017 · 3 comments

Comments

@defusioner
Copy link

The problem

Hello! I'm using webdriverio to go to the page, scrub some feeds and display them via css selectors. However, I'm seeing some strange behavior with selectors, ex.:

  1. I load a feed and display: posts, likes, texts Here it's good
  2. I load a feed, scroll it 2 times and do the same thing Still good
  3. I load a feed and scroll 3 times: here I get Error: connect ECONNREFUSED 127.0.0.1:9515 running the code
const ids = await browser.getAttribute('.wall_module .post.own', 'id');
  console.log('ids', ids);
  const posts =  await browser.getText('.wall_module .post.own .post_info .wall_post_text');
  console.log('posts', posts);
  const likes = await browser.getText('.wall_module .post.own .post_info .post_like_count._count');
  console.log('likes', likes);

Have I missed some promise returns? Feels like chrome can't work with "quite big" selectors. I join my code for tests. Simply call await scrollForNewPosts(browser); 1, 2 or more times to get the error. Thanks!

Environment

  • WebdriverIO version: 4.6.2
  • Node.js version: 7.9.0

Code To Reproduce Issue [ Good To Have ]

const webdriverio = require('webdriverio');
const chromedriver = require('chromedriver');

// This should be the path to your Canary installation.
// I'm assuming Mac for the example.
const PATH_TO_CANARY = 'C:\\Users\\Fnac\\AppData\\Local\\Google\\Chrome SxS\\Application\\chrome.exe';
const PORT = 9515;

chromedriver.start([
  '--url-base=wd/hub',
  `--port=${PORT}`,
  '--verbose'
]);

const scrollForNewPosts = async browser => {
  await browser.scroll('.flat_button.secondary_dark.more_link');
  await browser.scroll('.wall_module .post.own .page_post_sized_thumbs');

  await browser.waitUntil(async () => {
    const classes = await browser.getAttribute('.flat_button.secondary_dark.more_link', 'class');
    console.log('classes', classes);
    return classes.indexOf('flat_btn_lock') === -1;
  }, 5000);
};

const showInfo = async browser => {
  const ids = await browser.getAttribute('.wall_module .post.own', 'id');
  console.log('ids', ids);
  const posts =  await browser.getText('.wall_module .post.own .post_info .wall_post_text');
  console.log('posts', posts);
  const likes = await browser.getText('.wall_module .post.own .post_info .post_like_count._count');
  console.log('likes', likes);
};

const sleep = ms => {
  setTimeout(() => {}, ms);
};

(async () => {
  const opts = {
    port: PORT,
    desiredCapabilities: {
      browserName: 'chrome',
      chromeOptions: {
        binary: PATH_TO_CANARY,
        args: ['--headless']
      }
    }
  };
  const browser = webdriverio.remote(opts).init();
  await browser.url('https://vk.com/filternative');
  await browser.click('.wall_module .page_block .ui_tabs li:nth-child(2) a');

  await scrollForNewPosts(browser);
  await scrollForNewPosts(browser);
  await scrollForNewPosts(browser);

  console.log('scrolled 3 times');

  await showInfo(browser);
})();
@dangmai
Copy link

dangmai commented Oct 19, 2017

I definitely have run into this as well, it seems that whenever a selector returns "a lot" of things I'll run into a ConnectException - for example here's the stdout for some commands:

COMMAND: POST http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/elements - {"using":"css selector","value":"table#pb_packetDoc span.fancytree-title"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":[{"ELEMENT":"0.6957567264485653-7"},{"ELEMENT":"0.6957567264485653-8"},{"ELEMENT":"0.6957567264485653-9"},{"ELEMENT":"0.6957567264485653-10"},{"ELEMENT":"0.6957567264485653-11"},{"ELEMENT":"0.6957567264485653-12"},{"ELEMENT":"0.6957567264485653-13"},{"ELEMENT":"0.6957567264485653-14"},{"ELEMENT":"0.6957567264485653-15"},{"ELEMENT":"0.6957567264485653-16"},"(2 more items)"]}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-7/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-8/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-9/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-10/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-11/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-12/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-13/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-14/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-15/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-16/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-17/text - {}
COMMAND: GET http://127.0.0.1:4444/wd/hub/session/fee59253aa77784d51803d562eaa9d5d/element/0.6957567264485653-18/text - {}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"1"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"2"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"3"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"4"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"5"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"6"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"7"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"8"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"9"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"10"}
RESULT: {"sessionId":"fee59253aa77784d51803d562eaa9d5d","status":0,"value":"11"}
RESULT: {"message":"java.net.ConnectException: Connection refused: connect","type":"RuntimeError","seleniumStack":{"status":13,"type":"UnknownError","message":"An unknown server-side error occurred while processing the command.","orgStatusMessage":"java.net.ConnectException: Connection refused: connect"}}

It manages to get the text of the first 11 elements, but fails at the last one.

@christian-bromann
Copy link
Member

@defusioner @dangmai this has to do with the amount of parallel requests you do to the Selenium server. There is a limitation to it and if you try to get the text of 100 elements at the same time it throws an error like this because it can't handle 100 requests at the same time. I recommend to specify the element selector better.

However WebdriverIO should make sure that it doesn't run too many commands.

@christian-bromann
Copy link
Member

This is fixed with latest version.

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

No branches or pull requests

3 participants