appium / appium-mac2-driver

Next-gen Appium macOS driver, backed by Apple XCTest
Apache License 2.0
125 stars 24 forks source link

Could not proxy command to the remote server #170

Closed phanzy closed 1 year ago

phanzy commented 1 year ago

Getting could not proxy command to the remote server error on pretty much every other test run. There is only one test that runs on one Mac mini so it shouldn't be a matter of resources. Please help.

MacOS 12.4 Appium 2.0.0-beta.43 Xcode Version 13.4.1 (13F100) Node v18.4.0

Appium Server start command: appium --allow-insecure=apple_script -p 4723 --log appium.log

[HTTP] --> POST /session/2037b0d1-50ba-4fae-bf79-1b1f1da41b33/element
[HTTP] {"using":"-ios class chain","value":"**/XCUIElementTypeButton[`title == \"Profiles\"`]"}
[debug] [Mac2Driver@25bf (2037b0d1)] Calling AppiumDriver.findElement() with args: ["-ios class chain","**/XCUIElementTypeButton[`title == \"Profiles\"`]","2037b0d1-50ba-4fae-bf79-1b1f1da41b33"]
[debug] [Mac2Driver@25bf (2037b0d1)] Valid locator strategies for this request: id, name, accessibility id, xpath, class name, -ios predicate string, predicate string, -ios class chain, class chain
[debug] [WD Proxy] Matched '/element' to command name 'findElement'
[debug] [WD Proxy] Proxying [POST /element] to [POST http://127.0.0.1:10100/session/39D226D6-E7AE-473E-A7D3-7999E065006F/element] with body: {"using":"class chain","value":"**/XCUIElementTypeButton[`title == \"Profiles\"`]"}
[WD Proxy] connect ECONNREFUSED 127.0.0.1:10100
[debug] [Mac2Driver@25bf (2037b0d1)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: connect ECONNREFUSED 127.0.0.1:10100
[debug] [Mac2Driver@25bf (2037b0d1)]     at WDAMacProxy.command (/Users/gandalfqe/.appium/node_modules/appium-mac2-driver/node_modules/@appium/base-driver/lib/jsonwp-proxy/proxy.js:342:13)
[debug] [Mac2Driver@25bf (2037b0d1)]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[debug] [Mac2Driver@25bf (2037b0d1)]     at Mac2Driver.findElOrEls (/Users/gandalfqe/.appium/node_modules/appium-mac2-driver/lib/commands/find.js:17:10)
[debug] [Mac2Driver@25bf (2037b0d1)]     at Mac2Driver.findElOrElsWithProcessing (/Users/gandalfqe/.appium/node_modules/appium-mac2-driver/node_modules/@appium/base-driver/lib/basedriver/commands/find.js:80:16)
[debug] [Mac2Driver@25bf (2037b0d1)]     at Mac2Driver.findElement (/Users/gandalfqe/.appium/node_modules/appium-mac2-driver/node_modules/@appium/base-driver/lib/basedriver/commands/find.js:21:14)
mykola-mokhnach commented 1 year ago

The approach to investigation is similar to https://github.com/appium/appium-uiautomator2-driver#socket-hangup-error

Try to fetch the xcodebuild log to see more details

phanzy commented 1 year ago

Thanks, Mykola. So it seems as though I'm getting this issue because of the session replacement. Does this happen when one session times out?

[debug] [WD Proxy] Got response with status 200: {"value":null,"sessionId":"9991B2D7-EC8A-4387-9E95-30B31AAD011A"} [WD Proxy] Replacing sessionId 9991B2D7-EC8A-4387-9E95-30B31AAD011A with b59608ae-8782-4867-ad0a-67cf6163115a [HTTP] <-- POST /session/b59608ae-8782-4867-ad0a-67cf6163115a/element/E28CA650-4625-43F4-B8E7-7B098279A867/click 200 763 ms - 65

mykola-mokhnach commented 1 year ago

No, this is a normal behaviour. the internal session identifier that the server has is different from the one your local client uses, so it must be replaced in order to proxy it properly

phanzy commented 1 year ago

So is there a new session created for every application under test? If so, does the client change the sessionid automatically?

mykola-mokhnach commented 1 year ago

A new session is created every time https://w3c.github.io/webdriver/#dfn-new-sessions request is received.

If so, does the client change the sessionid automatically?

Not sure what you mean

phanzy commented 1 year ago

Thanks Mykola