2

I'm building a Selenium Grid systems in Kubernetes with Chrome and Firefox nodes and a hub.

The tests goes well with 3 times invoke or 6 sessions in queue. But when it goes higher, the console will return a 504 error. Here is the code:

  let driver = new Builder()
    .usingServer("https://example.com/")  
    .withCapabilities(capabilities)
    .setChromeOptions(chromeOptions)
    .build();
  try {
    console.log("Execution Start..............", Date());
    await driver.get('http://www.google.com');
    console.log("After get..............", Date());
    // Enter text "cheese" and perform keyboard action "Enter"
    await driver.findElement(By.name('q')).sendKeys('tester', Key.ENTER);
    console.log("After findElement..............", Date());
    let firstResult = await driver.wait(until.elementLocated(By.css('h3')), 10000);
    console.log("Before firstResult..............", Date());
    console.log(await firstResult.getAttribute('textContent'));
    console.log("After firstResult..............", Date());
  } finally {
    console.log("Execution end..............", Date());
    await driver.quit();
  }
}

And here is the output:

    Execution end.............. Sun Dec 19 2021 19:39:11 GMT+0700 (Indochina Time)
    (node:96313) UnhandledPromiseRejectionWarning: WebDriverError: <html>
    <head><title>504 Gateway Time-out</title></head>
    <body>
    <center><h1>504 Gateway Time-out</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>

        at parseHttpResponse (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:664:11)
        at Executor.execute (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:573:28)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:96313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
    (node:96313) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    (node:96313) UnhandledPromiseRejectionWarning: WebDriverError: <html>
    <head><title>504 Gateway Time-out</title></head>
    <body>
    <center><h1>504 Gateway Time-out</h1></center>
    <hr><center>nginx</center>
    </body>
    </html>

        at parseHttpResponse (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:664:11)
        at Executor.execute (/SeleniumGrid/node_modules/selenium-webdriver/lib/http.js:573:28)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
    (node:96313) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 8)

I think the error appear and the await driver.get('http://www.google.com'); line. Does anyone know how to fix it?

Chuong Nguyen
  • 1,077
  • 6
  • 15
  • Does [_this_](https://stackoverflow.com/questions/60451310/502-bad-gateway-nginx-with-selenium-and-django/60453469#60453469) or [_this_](https://stackoverflow.com/questions/62712583/504-gateway-time-out-error-using-firefox-68-9-0esr-in-headless-mode-with-geckodr/62713621#62713621) discussion helps you? – undetected Selenium Dec 19 '21 at 17:37
  • Hi @DebanjanB , I don't think so because I don't use web server. I call directly from localhost to the selenium hub. And it only happens when we have a lot of sessions. If 1 or 2 sessions, it still works fine – Chuong Nguyen Dec 20 '21 at 02:05
  • Did your issue got solved? @Chuong Nguyen – Jagruuti Jun 22 '23 at 10:28

0 Answers0