java-client
java-client copied to clipboard
Appium client hung waiting on socket read when server logs 404
Description:
I am writing tests using the Page Object Model pattern. I love the annotations. On iOS, I will occasionally see my test application hang when one of my annotated elements is referenced and the Appium server has logged a 404 for a stale element. It seems like it did not respond to the client with the error and the client hangs waiting for a response.
Environment:
- java-client 7.4.1
- Appium server: 2.0.0-beta.25
- Desktop OS: macOS Monterey 12.1
- Mobile platform: iOS 14.7.1
- Real device iPhone SE
Details:
I am using Page Object Model features. In my implementation, I have a parent Page class which calls a waitForPageVisible function for each derived class. The waitForPageVisible method will reference one of my annotated variables which should result in appium doing its magic FindBy stuff.
e.g., my derived class has the following:
@AndroidFindBy(id = "com.co.android.apps.connectmobile:id/button_submit")
@iOSXCUITFindBy(accessibility = "submit_button_id")
@WithTimeout(time = WITH_TIMEOUT_MEDIUM, chronoUnit = ChronoUnit.SECONDS)
lateinit var submitButton: MobileElement
override fun waitForPageVisible() {
submitButton.isDisplayed
}
Stacktraces
When this function is called, I have seen cases where the client hangs with the following call stack. I am not familiar with the internals of the java client, but I do notice that the stack does not have any kind of wait loop that I could see which I would have expected given the annotations. But the stack indicates the program is stuck on the socket read waiting for a response. gist of stacktrace
Appium logs
And my appium server log is displaying this message with the 404 and what appears to be an incomplete message ending in 3 dots. gist of the end of the Appium server log
It would be nice to get the actual stack of Appium server (e.g. the corresponding Node process) itself when that happens
Also, does the server respond to other requests during that time?
Sorry about the server log. Everything was looking good right up until it had the 404. And the server is still alive and will respond normally when starting a new test which creates a new driver.
This happens very rarely, but when it does it is annoying. I have just added the capability setting commandTimeouts: 24000 to my config in hopes that at least my client will timeout. But it would be interesting to understand the underlying issue.
I would try then to enable verbose logging for netty, which is the default http client used in selenium and see what it logs. Perhaps, the server does not return what it wants (e.g. some wrong http headers) and thus an endless waiting loop happens.
Also the local network traffic sniffing might be useful
I am curious if this is something brand new or have you seen something like this before?
No, I did not observe such issues before