SessionNotFoundException when running at scale, but not with one node

When I attempt to run a couple of hundred Selenium tests against 6 iOS Appium nodes (each one is a separate VM), some of my tests succeed, but many are failing with “Requested a new session but one was in progress”. I generally don’t have this issue when I’m running against a single node in order to troubleshoot.

My test automation is requesting more sessions than there are available nodes, but the Selenium grid server should handle that by queuing them up. (And when I look at the grid console, it appears to be doing so.)

I’ve read that the only way to avoid this is to restart the Appium instance between tests. (An undesireable hack.) Session clobbering doesn’t help, either - it just causes errors on subsequent requests or violates the maxInstances config parameter.

I can’t seem to figure out what I’m doing wrong - any suggestions, please?

{ "capabilities": [ { "browserName": "Safari", "simulator":true, "deviceName":"iPhone 6", "maxInstances": 1, "platformName": "iOS", "platformVersion": 8.1, "acceptSslCerts":true, "safariAllowPopups":false, "autoAcceptAlerts":true, "applicationName":"node-07" } ], "configuration": { "cleanUpCycle":2000, "timeout":300000, "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy", "url":"", "host":"", "port":5555, "maxSession": 1, "register": true, "registerCycle":5000, "hubPort": 4444, "hubHost": "" } }

Webdriver capabilities:
DesiredCapabilities safariIphone = new DesiredCapabilities(); safariIphone.setCapability("browserName", "Safari"); safariIphone.setCapability("platformName", "iOS"); safariIphone.setCapability("platformVersion", "8.1"); safariIphone.setCapability("deviceName", "iPhone 6"); safariIphone.setCapability("keepKeyChains", true); safariIphone.setCapability("autoAcceptAlerts", true); safariIphone.setCapability("acceptSslCerts", true); safariIphone.setCapability("safariAllowPopups", false); safariIphone.setJavascriptEnabled(true);