Search code examples
seleniumsshautomated-testsgeckodrivermobaxterm

SSH Selenium Session Crashes on Logout (even with "screen", "nohup" etc)


I'm running a Selenium webscraper in Java on a Linux server through SSH, but the browser crashes upon termination of the session despite various attempts to instruct the program to run in the background. Specifically, I've used screen, tmux, nohup, disown, and setsid (as here https://www.tecmint.com/keep-remote-ssh-sessions-running-after-disconnection/) with similar, bad results. I would like to try a VNC session, but so far not enabled on the server.

With screen for example:

  1. I type screen, run the program, and normal output is produced
  2. I detach the screen with Ctrl+a+d, normal output continues to be produced
  3. I end the SSH session. Output ceases and (upon logging back in and returning to the screen session), I get the error message
Exiting due to channel error
Exiting due to channel error
Exiting due to channel error
Exiting due to channel error
Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to decode response from marionette

I've tried this a couple of times, so it's not a coincidence that it crashes at the exact time of ending the SSH session. What could be going wrong and how can I try to diagnose the issue?

System information:

OS: Red Hat Enterprise Linux, Linux 3.10.0-1127.10.1.el7.x86_64
Java: 1.8.0_252
Firefox version: Mozilla Firefox 78.3.1esr
Firefox boot options: "--marionette" "-headless" "-foreground" "-no-remote" "-profile"
Gecko driver version: 0.27.0
Selenium version: 3.141.59m revision e82be7d358
SSH client: MobaXTerm, personal version 10.4

Solution

  • Through sheer dumb trial and error luck I tried swapping MobaXTerm for PuTTY (continuing to use screen) and the problem went away. I have no idea why this works. The universe is a complex place which surpasses mere human comprehension.