patrol icon indicating copy to clipboard operation
patrol copied to clipboard

Tests not initialising due to Unhandled Exception: ClientException with SocketException: Connection refused

Open Ifrakhan2k2 opened this issue 4 months ago • 3 comments

Steps to reproduce

integrate with lambdatest build app apks using patrol build android run the tests on Lambdatest app automate

Actual results

The app stays stuck on a black screen the logs show the exception

E flutter : [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: ClientException with SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 58456, uri=http://localhost:8081/initialize

The tests are running fine on locally

Logs

Logs
<!----------- beginning of main
08-18 12:17:21.008 20604 20673 E Adreno-AppProfiles: QSPM AIDL service doesn't exist
08-18 12:17:21.651 20604 20604 E om.nikahforever: Unable to open libpenguin.so: dlopen failed: library "libpenguin.so" not found.
08-18 12:17:21.691 20604 20604 E flutter : [ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: ClientException with SocketException: Connection refused (OS Error: Connection refused, errno = 111), address = localhost, port = 58456, uri=http://localhost:8081/initialize
08-18 12:17:21.691 20604 20604 E flutter : #0      IOClient.send (package:http/src/io_client.dart:154:7)
08-18 12:17:21.691 20604 20604 E flutter : <asynchronous suspension>
08-18 12:17:21.691 20604 20604 E flutter : #1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:93:32)
08-18 12:17:21.691 20604 20604 E flutter : <asynchronous suspension>
08-18 12:17:21.691 20604 20604 E flutter : #2      Future.timeout.<anonymous closure> (dart:async/future_impl.dart:1064:7)
08-18 12:17:21.691 20604 20604 E flutter : <asynchronous suspension>
08-18 12:17:21.691 20604 20604 E flutter : #3      NativeAutomatorClient._sendRequest (package:patrol/src/native/contracts/native_automator_client.dart:253:22)
08-18 12:17:21.691 20604 20604 E flutter : <asynchronous suspension>
08-18 12:17:21.691 20604 20604 E flutter : #4      NativeAutomator._wrapRequest (package:patrol/src/native/native_automator.dart:234:22)
08-18 12:17:21.691 20604 20604 E flutter : <asynchronous suspension>
08-18 12:17:21.691 20604 20604 E flutter : #5      NativeAutomator.initialize (package:patrol/src/native/native_automator.dart:276:5)
08-18 12:17:21.691 20604 20604 E flutter : <asynchronous suspension>
08-18 12:17:21.691 20604 20604 E flutter : #6      main (file:///Users/ifra/Desktop/nf-app-flutter/integration_test/test_bundle.dart:13:3)
08-18 12:17:21.691 20604 20604 E flutter : <asynchronous suspension>
08-18 12:17:21.691 20604 20604 E flutter : -->

Patrol version

patrol_cli v3.7.0

Patrol Doctor output

Patrol Doctor output
<!-- Patrol doctor:
Patrol CLI version: 3.7.0
Flutter command: flutter 
  Flutter 3.32.8 • channel stable
Android: 
• Program adb found in /Users/ifra/Library/Android/sdk/platform-tools/adb
• Env var $ANDROID_HOME set to /Users/ifra/Library/Android/sdk
iOS / macOS: 
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller found in /usr/local/bin/ideviceinstaller -->

Flutter Doctor output

Flutter Doctor output
<!-- [✓] Flutter (Channel stable, 3.32.8, on macOS 15.6 24G84 darwin-x64, locale en-IN) [374ms]
    • Flutter version 3.32.8 on channel stable at /Users/ifra/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision edada7c56e (4 weeks ago), 2025-07-25 14:08:03 +0000
    • Engine revision ef0cd00091
    • Dart version 3.8.1
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.3s]
    • Android SDK at /Users/ifra/Library/Android/sdk
    • Platform android-36, build-tools 36.0.0
    • ANDROID_HOME = /Users/ifra/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✗] Xcode - develop for iOS and macOS [240ms]
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      For installation instructions, see https://guides.cocoapods.org/using/getting-started.html#installation

[✓] Chrome - develop for the web [89ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.2) [87ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.103.1) [84ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.116.0

[✓] Connected device (2 available) [379ms]
    • macOS (desktop) • macos  • darwin-x64     • macOS 15.6 24G84 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 139.0.7258.128

[✓] Network resources [571ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.-->

Ifrakhan2k2 avatar Aug 19 '25 07:08 Ifrakhan2k2

the lambdatest Logs give the following error Raw Instrumentation Logs INSTRUMENTATION_STATUS: class=com.nikahforever.MainActivityTest INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS: id=AndroidJUnitRunner INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stream= com.nikahforever.MainActivityTest: INSTRUMENTATION_STATUS: test=initializationError INSTRUMENTATION_STATUS_CODE: 1 INSTRUMENTATION_STATUS: class=com.nikahforever.MainActivityTest INSTRUMENTATION_STATUS: current=1 INSTRUMENTATION_STATUS: id=AndroidJUnitRunner INSTRUMENTATION_STATUS: numtests=1 INSTRUMENTATION_STATUS: stack=java.lang.RuntimeException: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 403, Forbidden: You tried to target undefined but got blocked. It can be related to your blacklist or whitelist settings or the target site is not allowed by Bright Data policy. Read more: https://docs.brightdata.com/proxy-networks/faqs#what-is-error-code-403 at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:135) at com.nikahforever.MainActivityTest.testCases(MainActivityTest.java:32) ... 21 trimmed Caused by: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 403, Forbidden: You tried to target undefined but got blocked. It can be related to your blacklist or whitelist settings or the target site is not allowed by Bright Data policy. Read more: https://docs.brightdata.com/proxy-networks/faqs#what-is-error-code-403 at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest(PatrolAppServiceClient.kt:47) at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest$default(PatrolAppServiceClient.kt:27) at pl.leancode.patrol.contracts.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:18) at pl.leancode.patrol.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:46) at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:123) ... 23 more INSTRUMENTATION_STATUS: stream= Error in initializationError(com.nikahforever.MainActivityTest): java.lang.RuntimeException: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 403, Forbidden: You tried to target undefined but got blocked. It can be related to your blacklist or whitelist settings or the target site is not allowed by Bright Data policy. Read more: https://docs.brightdata.com/proxy-networks/faqs#what-is-error-code-403 at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:135) at com.nikahforever.MainActivityTest.testCases(MainActivityTest.java:32) ... 21 trimmed Caused by: pl.leancode.patrol.contracts.PatrolAppServiceClientException: Invalid response 403, Forbidden: You tried to target undefined but got blocked. It can be related to your blacklist or whitelist settings or the target site is not allowed by Bright Data policy. Read more: https://docs.brightdata.com/proxy-networks/faqs#what-is-error-code-403 at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest(PatrolAppServiceClient.kt:47) at pl.leancode.patrol.contracts.PatrolAppServiceClient.performRequest$default(PatrolAppServiceClient.kt:27) at pl.leancode.patrol.contracts.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:18) at pl.leancode.patrol.PatrolAppServiceClient.listDartTests(PatrolAppServiceClient.kt:46) at pl.leancode.patrol.PatrolJUnitRunner.listDartTests(PatrolJUnitRunner.java:123) ... 23 more INSTRUMENTATION_STATUS: test=initializationError INSTRUMENTATION_STATUS_CODE: -2

Ifrakhan2k2 avatar Aug 22 '25 18:08 Ifrakhan2k2

@bartekpacia please do address the issue when you get time. I use patrol but this is forcing us to consider other options since the tests are no longer running.

Ifrakhan2k2 avatar Aug 27 '25 11:08 Ifrakhan2k2

hey @Ifrakhan2k2 sorry but I don't work on Patrol anymore. I'm sure the great team at LeanCode will help you :)

bartekpacia avatar Aug 27 '25 14:08 bartekpacia

Hi @Ifrakhan2k2 sorry for lateee response. I have some questions:

  1. What is your patrol version?
  2. Did you follow docs https://patrol.leancode.co/documentation/integrations/lambdatest#change-runner?
  3. Did you maybe try to run this apk on Firebase Test lab for example? To be sure that they working in other Farm? (It can be done in free plan)

Kendru98 avatar Nov 19 '25 12:11 Kendru98

Hi @Ifrakhan2k2 sorry for lateee response. I have some questions:

  1. What is your patrol version?
  2. Did you follow docs https://patrol.leancode.co/documentation/integrations/lambdatest#change-runner?
  3. Did you maybe try to run this apk on Firebase Test lab for example? To be sure that they working in other Farm? (It can be done in free plan)

Hi I also faced the same issue with him, could you pls help us to check?

  1. The issue happens with both Patrol v3.20.0 and v3.19.0
  2. Yes, I already changed the runner to testInstrumentationRunner "pl.leancode.patrol.LambdaTestPatrolJUnitRunner"
  3. Haven't tried but with the same code it still worked last week but this week it doesn't

minhhoangtn avatar Nov 26 '25 01:11 minhhoangtn