Appium with XCode 9 for iOS 11

Problem:
I have upgraded XCode to 9 and Appium to 1.7/1.6.5 and trying to execute few test cases on mobile web.
Code:

_DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“deviceName”, “iPhone”);
capabilities.setCapability(“udid”, “”);
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“automationName”, “XCUITest”);
capabilities.setCapability(“browserName”, “Safari”);
capabilities.setCapability(“newCommandTimeout”,180);
capabilities.setCapability(“webkitResponseTimeout”, 70000);
capabilities.setCapability(“networkConnectionEnabled”,true);
capabilities.setCapability("–session-override",true);

driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Thread.sleep(5000);
driver.get(“https://”);
Thread.sleep(10000);
driver.findElement(By.xpath("//*[@id=’’]")).click();_
Sometimes the test case run properly but sometimes it gives error as mentioned below:
Sep 22, 2017 9:19:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread “main” org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: ‘3.5.3’, revision: ‘’, time: ‘2017-08-29T12:42:**’
System info: host: ‘MacBook-Pro.local’, ip: ‘’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.12.6’, java.version: ‘1.8.0_40’
Driver info: driver.version: RemoteWebDriver
Capabilities [{networkConnectionEnabled=true, webkitResponseTimeout=70000, --session-override=true, databaseEnabled=false, deviceName=iPhone, platform=MAC, newCommandTimeout=180, webStorageEnabled=false, locationContextEnabled=false, automationName=XCUITest, browserName=Safari, takesScreenshot=true, javascriptEnabled=true, udid=, platformName=MAC}]

Also, on looking at appium server logs, I get the below error:

_[debug] [RemoteDebugger] Webkit response timeout: 70000
[debug] [RemoteDebugger] Receiving WebKit data: {“result”:{“result”:{“type”:“string”,“value”:"{“status”:0,“value”:null}"},“wasThrown”:false},“id”:3}
[debug] [RemoteDebugger] Found handler for message ‘3’
[debug] [RemoteDebugger] Received result for atom ‘click’ execution: null
[debug] [MJSONWP] Responding to client with driver.click() result: null
[HTTP] <-- POST /wd/hub/session/**/element/5000/click 200 942 ms - 76
[debug] [RemoteDebugger] Receiving WebKit data: {“method”:“Canvas.canvasMemoryChanged”,“params”:{“canvasId”:“canvas:0.3”,“memoryCost”:32000}}
TypeError: Cannot read property ‘wasThrown’ of undefined
at WebKitRpcClient.receive (…/…/lib/webkit-rpc-client.js:117:38)
at emitTwo (events.js:106:13)
at WebSocket.emit (events.js:191:7)
at Receiver.ontext (/usr/local/lib/node_modules/appium/node_modules/ws/lib/WebSocket.js:841:10)
at /usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:536:18
at Receiver.applyExtensions (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:371:5)
at /usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:508:14
at Receiver.flush (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:347:3)
at Receiver.finish (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:541:12)
at Receiver.expectHandler (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:499:31)
at Receiver.add (/usr/local/lib/node_modules/appium/node_modules/ws/lib/Receiver.js:103:24)
at Socket.realHandler (/usr/local/lib/node_modules/appium/node_modules/ws/lib/WebSocket.js:825:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (stream_readable.js:134:10)
at TCP.onread (net.js:548:20)

Also to add, the steps sometimes work and sometimes doesn’t.
Can you please help.