iPhone refuses to create any new sessions after failure

I am using Appium 1.5.3 as part of a Selenium Grid.

I have a test iPhone 6s running iOS 9.3.1

I have an issue that after some failures the device gets stuck in a state where it refuses to create any new sessions. The only way to fix it seems to be to kill and restart the Appium instance driving the phone.

Has anyone else experienced this problem? Is there any kind of work around or solution for it (other than having to restart Appium)?

The original failure that seems to put Appium in a bad state:

"org.openqa.selenium.WebDriverException: Session [5b2874b4-3982-482c-8580-91a3a451f8e1] was terminated due to FORWARDING_TO_NODE_FAILED Command duration or timeout: 5

I have also sometimes come across this error in the logs too:

“error”: "org.openqa.selenium.WebDriverException: Error forwarding the new session Empty pool of VM for setup Capabilities [{browserName=safari, platformName=iOS, device=null, deviceName=ANY, version=iphone6, platform=MAC, applicationName=ANY}]\nCommand duration or timeout: 3 milliseconds

The subsequent errors every time trying to run a test again:

“error”: "org.openqa.selenium.SessionNotCreatedException: A new session could not be created. Details: Problem getting session data for driver type IosDriver; does it implement ‘get driverData’? (WARNING: The server did not provide any stacktrace information)

I have also seen this error:

[iOSLog] [IOS_SYSLOG_ROW] Sep 14 14:24:02 Jokl-Tech-iPhone-6S MobileGestaltHelper[90] : libMobileGestalt MobileGestalt.c:281: server_access_check denied access to question UniqueDeviceID for pid 268
[iOSLog] [IOS_SYSLOG_ROW] Sep 14 14:24:02 Jokl-Tech-iPhone-6S syncdefaultsd[268] : libMobileGestalt MobileGestaltSupport.m:151: pid 268 (syncdefaultsd) does not have sandbox access for re6Zb+zwFKJNlkQTUeT+/w and IS NOT appropriately entitled
[iOSLog] [IOS_SYSLOG_ROW] Sep 14 14:24:02 Jokl-Tech-iPhone-6S syncdefaultsd[268] : libMobileGestalt MobileGestalt.c:542: no access to UniqueDeviceID (see rdar://problem/11744455)

I found references to it on a Calibash / Xamarin forum. It mentioned that it was an issue in one of Apple’s scripts. It suggested restarting the device. I did that. Things worked initially but it soon broke again and I am back to “FORWARDING_TO_NODE_FAILED” followed by SessionNotCreatedException

We are facing the same issue.
Did you find the workaround for it?

Unfortunately not so far. I am having to stop and restart the proxy and the Appium instance driving the phone every time it gets stuck in this state. I don’t know that there is a straightforward way to work around this and automate it.

The proxy is being run through the ‘ios-webkit-debug-proxy-launcher.js’ script that is supposed to automatically recover from errors.

I might be able to have some Jenkins post job task that looks for the error(s) in the test output. Then it would have to signal something on the box to restart the scripts. This is not a trivial task besides, it is just trying to compensate for the problem. It is not a fixing the underlying problem causing Appium to get into this state.