appium / appium-flutter-driver

Appium Flutter Driver is a test automation tool for Flutter apps on multiple platforms/OSes. Appium Flutter Driver is part of the Appium mobile test automation tool maintained by community
MIT License
463 stars 184 forks source link

Cannot connect to the Dart Observatory #567

Closed yyuanmeme closed 1 year ago

yyuanmeme commented 1 year ago

I cannot link to the latest session this last session is http://127.0.0.1:35783/iRofrcdoJzY=/ this is adb log: ibu_mini4@DST016446 ~ % adb logcat|grep http://1
09-15 17:36:18.398 22609 23134 I flutter : The Dart VM service is listening on http://127.0.0.1:41717/zUlNllqYu1s=/ 09-15 17:54:13.703 28511 29000 I flutter : The Dart VM service is listening on http://127.0.0.1:36669/DBXZ8BdoEYE=/ 09-15 17:55:09.807 29435 30131 I flutter : The Dart VM service is listening on http://127.0.0.1:42983/Ng6gZeQ4MYw=/ 09-15 18:02:40.952 31137 32645 I flutter : The Dart VM service is listening on http://127.0.0.1:45093/gNLCDM6VVFM=/ 09-15 18:08:29.275 2649 3509 I flutter : The Dart VM service is listening on http://127.0.0.1:39633/p_DX640wW00=/ 09-15 18:17:22.239 6105 7414 I flutter : The Dart VM service is listening on http://127.0.0.1:45581/9ICPiSR5_Qw=/ 09-15 18:18:34.423 7654 8687 I flutter : The Dart VM service is listening on http://127.0.0.1:33249/dXnuFmaNYe0=/ 09-15 18:26:02.695 13898 14699 I flutter : The Dart VM service is listening on http://127.0.0.1:36383/BtZMqXurTbA=/ 09-15 18:29:08.250 15337 16313 I flutter : The Dart VM service is listening on http://127.0.0.1:35783/iRofrcdoJzY=/

but Appium url is ws://127.0.0.1:33249/dXnuFmaNYe0=/ws, so I Cannot connect to the Dart Observatory

this is Appium log: [debug] [FlutterDriver] Establishing a connection to the Dart Observatory. Will retry 10 times with 3000ms delay between retries. These values could be customized by changing 'maxRetryCount' and 'retryBackoffTime' capabilities. [FlutterDriver] Attempt #1 of 10 [debug] [ADB] Forwarding system: 33249 to device: 33249 [debug] [ADB] Running '/users/ibu_mini4/library/android/sdk/platform-tools/adb -P 5037 -s RFCR30BKFQR forward tcp:33249 tcp:33249' [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #2 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #3 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #4 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #5 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #6 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #7 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #8 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #9 of 10 [FlutterDriver] {} [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #10 of 10 [FlutterDriver] {} [debug] [FlutterDriver@8080 (27b98653)] Deleting Flutter Driver session [debug] [AppiumDriver@8de9] Event 'newSessionStarted' logged at 1694773898011 (18:31:38 GMT+0800 (China Standard Time)) [debug] [AppiumDriver@8de9] Encountered internal error running command: Error: Cannot connect to the Dart Observatory URL ws://127.0.0.1:33249/dXnuFmaNYe0=/ws after 10 retries. Check the server log for more details

KazuCocoa commented 1 year ago

https://github.com/appium/appium-flutter-driver/pull/568 may help. You could apply the change to your local

KazuCocoa commented 1 year ago

Could you try out v1.23.0?

yyuanmeme commented 1 year ago

I want use the v1.23.0 but I try with "appium driver install --source=npm appium-flutter-driver" the version still v1.21.1

yyuanmeme commented 1 year ago

I try with "appium driver install --source local E:\work\2023\appium-flutter-driver\driver" was errored

the error is :silly logfile errno: -4048, silly logfile code: 'EPERM', silly logf

KazuCocoa commented 1 year ago

What about appium driver install --source=npm appium-flutter-driver@1.23.0? https://www.npmjs.com/package/appium-flutter-driver/v/1.23.0 exists, so unless your environment has custom npm repository (and not synced with latest), 1.23.0 should be available

yyuanmeme commented 1 year ago

Problem solved, thank you

rakhmatullov commented 1 year ago

The Driver 1.23.0 (specifically WebDriverAgent-Runner) is crashing for me with the simulator iOS 17.0. @KazuCocoa

KazuCocoa commented 1 year ago

Because it needs a newer XCUITest driver, that is no longer supports iOS 14 and lower. Let me update that as ios 17 is reaching https://github.com/appium/appium-flutter-driver/pull/572

KazuCocoa commented 1 year ago

Bump the xcuitest driver as flutter driver v2, that supports iOS 17+.

rakhmatullov commented 1 year ago

Thanks @KazuCocoa, I'll check soon.

rakhmatullov commented 1 year ago

@KazuCocoa There's some other problem with the driver of the version 1.23.0 as it works much longer than couple version back. I cannot yet fully confirm some specific delays, but seemingly it waits app idle rather long while the app is itself idle during all the wait time: " [Xcode] 2023-09-18 21:16:07.080093+0200 WebDriverAgentRunner-Runner[484:10589] Waiting up to 20s until com...QA is in idle state (including animations) [Xcode] t = 4053.07s Wait for com...QA to idle "

I know that it should be probably raised separately. But I don't have full confirm evidences yet. It's just a pre-notification to you.

rakhmatullov commented 1 year ago

This is seems to be actual for the release version of XCUITest driver (or other Appium modules involved) also. Many of the tests I use became up to 10 times slower with iOS 17.

rakhmatullov commented 1 year ago

@KazuCocoa I checked that the crash doesn't occur with the simulator iOS 17.0 after bumping XCUITest driver version. Thank you.

But the original problem is not solved for me: " [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=_-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. "

The drivers I have are: " ✔ Listing available drivers

KazuCocoa commented 1 year ago

Did you ensure that the device log has the observatory url?

rakhmatullov commented 1 year ago

No. Seemingly we have a problem from the app side. So thank you for the advices, we'll be discovering our side first.

baselalali commented 1 year ago

We have the same problem

baselalali commented 1 year ago
[Appium]   - flutter@1.23.0 (automationName 'Flutter')

\ I have the same problem on iOS real device>

[debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=_\-.\[\]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup.

cc @KazuCocoa

KazuCocoa commented 1 year ago

What only I could ask is if you could see the observatory url in your adb logcat/system log in the app start. If not present, the app side's something. e.g. release build, not complete https://github.com/appium/appium-inspector/issues/1115

baselalali commented 1 year ago

What I would like to ask is if you can see the observatory URL in your ADB logcat/system log when the app starts. I am using the iOS System/debug version of the app. The future app supports the Appium driver, and we have set up the Appium driver according to the guide. Additionally, the app has been launched successfully, and then the session interprets the observatory URL.

If it is not present in the app's logs, it could be due to something on the app side, such as a release build or an incomplete setup. You can find more information about this issue here: https://github.com/appium/appium-inspector/issues/1115. Does this mean the problem is on our side? Are there any workarounds for it?" CC: @KazuCocoa

baselalali commented 1 year ago

Did you ensure that the device log has the observatory url?

@KazuCocoa Should the observatory URL be printed or listed in the device log to avoid the error on iOS? Pls help: @rakhmatullov

[debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=_\-.\[\]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup.

KazuCocoa commented 1 year ago

Correct, it should be. Usually, you could observe the URL via console.log (mac host) for real devices

baselalali commented 1 year ago

"Thank you. Currently, we don't have the observatory URL in the device logs. Could this suggestion help me, or do you have any other ideas to avoid the error?"

Launch the app with flutter:launchApp for iOS and attach to the Dart VM: for users whom application under test do not print the observatory url via regular launch/activate app method
Start a session without app capability
Install the application under test via driver.install_app or mobile:installApp command etc
Calls flutter:launchApp command to start an iOS app via instrument service
driver.execute_script 'flutter:launchApp', 'com.example.bundleId', {arguments: ['arg1'], environment: {ENV1: 'env'}} is example usage
This launching method is the same as the above 3rd party method, but does the same thing only via the appium flutter driver.
KazuCocoa commented 1 year ago

What i could suggest is did you tried out profile build https://github.com/appium/appium-flutter-driver/tree/main?tab=readme-ov-file#usage-and-requirement ?

baselalali commented 1 year ago

We have added the profile in our app. And we are using debug version

# pubspec.yaml
dev_dependencies:
  flutter_driver:
    sdk: flutter
KazuCocoa commented 1 year ago

Have you tried profile build as well? In debug build, probably you need to start the process outside appium with ios-deploy (for example) to start the app process as debug mode. https://github.com/appium/appium-flutter-driver/issues/393#issuecomment-1692686293

baselalali commented 1 year ago

"Have you tried a profile build as well? No, I haven't tried a profile build."

"In a debug build, you may need to start the process outside of Appium with 'ios-deploy' (for example) to launch the app process in debug mode. Any example to do it?

We added my real test device to the profile list, so the app starts correctly on the device. After that the error accroiding to url is shwon ..

baselalali commented 1 year ago

@KazuCocoa, profile mode didn't provide a solution either. I made modifications by adding the finders and commands using enableFlutterDriverExtension(commands: [], finders: []);, but I encountered the same error: No observatory URL

Please support ..

KazuCocoa commented 1 year ago

If still the app did not print the observatory url, I don't have any ideas unfortunately... https://github.com/appium/appium-flutter-driver?tab=readme-ov-file#usage-and-requirement

baselalali commented 1 year ago

The app prints the URL on the connected device. Perhaps the driver cannot find the URL because the app is on a different network. Have you experienced any networking/port issues in this case? @KazuCocoa

KazuCocoa commented 1 year ago

This driver connects to the observatory url over the local port forward. If XCUITest driver itself worked to launch the test app for example, the port forward itself may not have issues. I haven't observed port forward related issues so far.

Could you create a new issue with the full Appium log and observatory url related device log as GIST?

DrashtiDD commented 1 year ago

Hi I am using appium-flutter-driver version 2.1.0 then too facing error as Cannot connect to the Dart Observatory URL ws://127.0.0.1:42097/ while automating flutter project on actual device

KazuCocoa commented 1 year ago

Could you create a new ticket with the full appium log and the device log such as logcat as GIST?

hakantektas commented 1 year ago

Got response with status 200: {"sessionId":"e74366a8-2911-40d6-a6cc-2b2100ff07e8","value":{"androidId":"984498fc80c22edf","apiVersion":"28","bluetooth":{"state":"OFF"},"brand":"samsung","carrierName":"","displayDensity":420,"locale":"tr_TR","manufacturer":"samsung","model":"SM-N950F","networks":[{"capabilities":{"SSID":null,"linkDownBandwidthKbps":1048576,"linkUpstreamBandwidthKbps":1048576,"networkCapabilities":"NET_CAPABILITY_WIFI_P2P,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_FOREGROUND,NET_CAPABILITY_NOT_SUSPENDED","signalStrength":-2147483648,"transportTypes":"TRANSPORT_WIFI"},"detailedState":"DISCONNECTED","extraInfo":null,"isAvailable":true,"isConnected":false,"isFailover":false,"isRoaming":false,"state":"DISCONNECTED","subtype":0,"subtypeName":"","type":13,"typeName":"WIFI_P2P"},{"capabilities":{"SSID":null,"linkDownBandwidthKbps":1048576,"linkUpstreamBandwidthKbps":1048576,"networkCapabilities":"NET_CAPABILITY_NOT_METERED,NET_CAPABILITY_INTERNET,NETCAPAB... [debug] [ADB] Waiting up to 20000ms for activity matching pkg: 'org.numixproject.croma' and activity: 'org.numixproject.croma.MainActivity' to be focused [debug] [ADB] Possible activities, to be checked: 'org.numixproject.croma.MainActivity', 'org.numixproject.croma.org.numixproject.croma.MainActivity' [debug] [ADB] Getting focused package and activity [debug] [ADB] Running '/Users/hakantektas/Library/Android/sdk/platform-tools/adb -P 5037 -s 988d9145524846413130 shell dumpsys window windows' [debug] [ADB] Found package: 'org.numixproject.croma' and fully qualified activity name : 'org.numixproject.croma.MainActivity' [debug] [FlutterDriver] Establishing a connection to the Dart Observatory. Will retry 10 times with 3000ms delay between retries. These values could be customized by changing 'maxRetryCount' and 'retryBackoffTime' capabilities. [FlutterDriver] Attempt #1 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #2 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #3 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #4 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #5 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #6 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #7 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #8 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #9 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [FlutterDriver] Waiting 3000ms before retrying [FlutterDriver] Attempt #10 of 10 [debug] [FlutterDriver] No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [debug] [FlutterDriver@5374 (1063c32f)] Deleting Flutter Driver session [debug] [AppiumDriver@705e] Event 'newSessionStarted' logged at 1698914567538 (11:42:47 GMT+0300 (GMT+03:00)) [debug] [AppiumDriver@705e] Encountered internal error running command: Error: Cannot determine the Dart Observatory URL after 10 retries. Original error: No observatory URL matching to '/(Observatory listening on |An Observatory debugger and profiler on\s.+\sis available at: |The Dart VM service is listening on )((http|\/\/)[a-zA-Z0-9:/=-.[]]+)/' was found in the device log. Please make sure the application under test is configured properly according to https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup. [debug] [AppiumDriver@705e] at connectSocket (/Users/hakantektas/node_modules/appium-flutter-driver/lib/sessions/observatory.ts:155:9) [debug] [AppiumDriver@705e] at startAndroidSession (/Users/hakantektas/node_modules/appium-flutter-driver/lib/sessions/android.ts:31:5) [debug] [AppiumDriver@705e] at FlutterDriver.createSession (/Users/hakantektas/node_modules/appium-flutter-driver/lib/sessions/session.ts:40:45) [debug] [AppiumDriver@705e] at AppiumDriver.createSession (/usr/local/lib/node_modules/appium/lib/appium.js:352:35) [HTTP] <-- POST /session 500 46268 ms - 1484

phoenixking25 commented 10 months ago

Someone gonna update this or not?>

balakumaran-deriv commented 8 months ago

Hello, any update on this?

lucasdiblasi-avenue commented 5 months ago

hey guys, any update?

rakhmatullov commented 5 months ago

I don't get this problem anymore.