mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.63k stars 254 forks source link

java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9080 on iOS Simulator test run #628

Closed edgarfroes closed 1 year ago

edgarfroes commented 1 year ago

Similarly to #595 and https://github.com/mobile-dev-inc/dadb/issues/48, this error occurs intermittently when trying to run flows with maestro test. In my local environment, this tends to happen when I have another terminal tab running maestro studio at the same time that I try to run maestro test, whether the maestro studio process is running or if the process had been closed a few seconds ago (conflicting background process?).

Maestro version 1.19.2 (installed via curl) Environment: Mac Pro M1 Max

Click to see the complete log

``` bash java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9080 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297) at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) at xcuitest.XCTestDriverClient.runningAppId(XCTestDriverClient.kt:55) at ios.xctest.XCTestIOSDevice.activeAppId(XCTestIOSDevice.kt:191) at ios.xctest.XCTestIOSDevice.contentDescriptor(XCTestIOSDevice.kt:48) at ios.LocalIOSDevice.contentDescriptor(LocalIOSDevice.kt:32) at maestro.drivers.IOSDriver.contentDescriptor(IOSDriver.kt:175) at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:344) at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:343) at maestro.utils.MaestroTimer.withTimeout(MaestroTimer.kt:16) at maestro.Maestro.findElementWithTimeout(Maestro.kt:343) at maestro.orchestra.Orchestra.findElement(Orchestra.kt:646) at maestro.orchestra.Orchestra.findElement$default(Orchestra.kt:628) at maestro.orchestra.Orchestra.tapOnElement(Orchestra.kt:558) at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:159) at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:443) at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:358) at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:185) at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:443) at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:358) at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:185) at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:137) at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:91) at maestro.orchestra.Orchestra.runFlow$default(Orchestra.kt:72) at maestro.cli.runner.TestSuiteInteractor.runFlow(TestSuiteInteractor.kt:136) at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:67) at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:45) at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:118) at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:100) at maestro.cli.session.MaestroSessionManager.newSession(MaestroSessionManager.kt:91) at maestro.cli.command.TestCommand.call(TestCommand.kt:100) at maestro.cli.command.TestCommand.call(TestCommand.kt:39) at picocli.CommandLine.executeUserObject(CommandLine.java:1933) at picocli.CommandLine.access$1200(CommandLine.java:145) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332) at picocli.CommandLine$RunLast.handle(CommandLine.java:2326) at picocli.CommandLine$RunLast.handle(CommandLine.java:2291) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159) at maestro.cli.DisableAnsiMixin$Companion.executionStrategy(DisableAnsiMixin.kt:22) at picocli.CommandLine.execute(CommandLine.java:2058) at maestro.cli.AppKt.main(App.kt:122) Suppressed: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9080 ... 55 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 54 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 54 more ```

edgarfroes commented 1 year ago

@dmitry-zaitsev is this problem getting tackled on 1.19.3 or 1.19.4?

idrakimuhamad commented 1 year ago

I also faced this whenever studio are running. Killing studio and then running test would be fine.

``` java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9080 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297) at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) at xcuitest.XCTestDriverClient.runningAppId(XCTestDriverClient.kt:55) at ios.xctest.XCTestIOSDevice.activeAppId(XCTestIOSDevice.kt:191) at ios.xctest.XCTestIOSDevice.contentDescriptor(XCTestIOSDevice.kt:48) at ios.LocalIOSDevice.contentDescriptor(LocalIOSDevice.kt:32) at maestro.drivers.IOSDriver.contentDescriptor(IOSDriver.kt:175) at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:344) at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:343) at maestro.utils.MaestroTimer.withTimeout(MaestroTimer.kt:16) at maestro.Maestro.findElementWithTimeout(Maestro.kt:343) at maestro.orchestra.Orchestra.findElement(Orchestra.kt:646) at maestro.orchestra.Orchestra.evaluateCondition(Orchestra.kt:374) at maestro.orchestra.Orchestra.assertConditionCommand(Orchestra.kt:204) at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:174) at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:137) at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:91) at maestro.cli.runner.MaestroCommandRunner.runCommands(MaestroCommandRunner.kt:120) at maestro.cli.runner.TestRunner$runContinuous$watchFiles$1$2$1.invoke(TestRunner.kt:88) at maestro.cli.runner.TestRunner$runContinuous$watchFiles$1$2$1.invoke(TestRunner.kt:87) at maestro.cli.runner.TestRunner.runCatching(TestRunner.kt:123) at maestro.cli.runner.TestRunner.access$runCatching(TestRunner.kt:23) at maestro.cli.runner.TestRunner$runContinuous$watchFiles$1$2.invoke(TestRunner.kt:87) at maestro.cli.runner.TestRunner$runContinuous$watchFiles$1$2.invoke(TestRunner.kt:75) at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30) Suppressed: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9080 ... 39 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 38 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 38 more ```

edgarfroes commented 1 year ago

@idrakimuhamad the problem is that my CI is failing 100% of times due to the same error.

edgarfroes commented 1 year ago

Below's the log the the error that's happening in the CI (Codemagic):

Click to see the complete log

``` bash java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9080 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297) at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) at xcuitest.XCTestDriverClient.runningAppId(XCTestDriverClient.kt:55) at ios.xctest.XCTestIOSDevice.activeAppId(XCTestIOSDevice.kt:191) at ios.xctest.XCTestIOSDevice.contentDescriptor(XCTestIOSDevice.kt:48) at ios.LocalIOSDevice.contentDescriptor(LocalIOSDevice.kt:32) at maestro.drivers.IOSDriver.contentDescriptor(IOSDriver.kt:175) at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:344) at maestro.Maestro$findElementWithTimeout$1.invoke(Maestro.kt:343) at maestro.utils.MaestroTimer.withTimeout(MaestroTimer.kt:16) at maestro.Maestro.findElementWithTimeout(Maestro.kt:343) at maestro.orchestra.Orchestra.findElement(Orchestra.kt:646) at maestro.orchestra.Orchestra.findElement$default(Orchestra.kt:628) at maestro.orchestra.Orchestra.tapOnElement(Orchestra.kt:558) at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:159) at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:443) at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:358) at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:185) at maestro.orchestra.Orchestra.runSubFlow(Orchestra.kt:443) at maestro.orchestra.Orchestra.runFlowCommand(Orchestra.kt:358) at maestro.orchestra.Orchestra.executeCommand(Orchestra.kt:185) at maestro.orchestra.Orchestra.executeCommands(Orchestra.kt:137) at maestro.orchestra.Orchestra.runFlow(Orchestra.kt:91) at maestro.orchestra.Orchestra.runFlow$default(Orchestra.kt:72) at maestro.cli.runner.TestSuiteInteractor.runFlow(TestSuiteInteractor.kt:136) at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:67) at maestro.cli.runner.TestSuiteInteractor.runTestSuite(TestSuiteInteractor.kt:45) at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:118) at maestro.cli.command.TestCommand$call$1.invoke(TestCommand.kt:100) at maestro.cli.session.MaestroSessionManager.newSession(MaestroSessionManager.kt:91) at maestro.cli.command.TestCommand.call(TestCommand.kt:100) at maestro.cli.command.TestCommand.call(TestCommand.kt:39) at picocli.CommandLine.executeUserObject(CommandLine.java:1933) at picocli.CommandLine.access$1200(CommandLine.java:145) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332) at picocli.CommandLine$RunLast.handle(CommandLine.java:2326) at picocli.CommandLine$RunLast.handle(CommandLine.java:2291) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159) at maestro.cli.DisableAnsiMixin$Companion.executionStrategy(DisableAnsiMixin.kt:22) at picocli.CommandLine.execute(CommandLine.java:2058) at maestro.cli.AppKt.main(App.kt:122) Suppressed: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9080 ... 55 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 54 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 54 more ```

amanjeetsingh150 commented 1 year ago

Below's the log the the error that's happening in the CI (Codemagic):

Hey @edgarfroes , Are you running maestro test command directly on CI?

amanjeetsingh150 commented 1 year ago

@idrakimuhamad Can you see if you are able to reproduce this in the latest version? If yes can you describe the steps will try to repro on my end

edgarfroes commented 1 year ago

@amanjeetsingh150 I'm blocked because of https://github.com/mobile-dev-inc/maestro/issues/646, can't run any tests anymore.

edgarfroes commented 1 year ago

@amanjeetsingh150 Is there anything I can do to speed this up? The tests were working just fine on CI on maestro 1.16.4, but they started to fail all of a sudden about 3 days ago without changes to workflows or environment versioning.

edgarfroes commented 1 year ago

@amanjeetsingh150 I downgraded to 1.16.4 and it's working for now. It had a bug where env variables didn't support apostrophes (which is now fixed on 1.17.x), so the downgraded version will work for now, but it's still failing on the CI with 1.17.5 so the issue is still valid.

amanjeetsingh150 commented 1 year ago

Hey @edgarfroes, are you using the maestro cloud or integrated maestro differently on your CI?

edgarfroes commented 1 year ago

@amanjeetsingh150 custom CI hosted on Codemagic.

arashgm commented 1 year ago

i faced the same issue locally when i had the Meastro studio open and trying to run a flow on simulator , after refreshing terminal the issue resolved but probabely there is a bug underneath

hunzai commented 1 year ago

I can confirm this is happening in 1.21.0 too

idrakimuhamad commented 1 year ago

Update

This issue doesn't happen if I already have a studio running, and then run a test. It only happen when I'm already running a test in continuous mode, and then running the studio.


On version 1.5, I've ran a test in continuous mode, and then ran studio. The app says some error happened and ask to refresh. In the terminal the below error were thrown.

``` java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9080 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297) at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) at xcuitest.XCTestDriverClient.runningAppId(XCTestDriverClient.kt:55) at ios.xctest.XCTestIOSDevice.activeAppId(XCTestIOSDevice.kt:197) at ios.xctest.XCTestIOSDevice.contentDescriptor(XCTestIOSDevice.kt:48) at ios.LocalIOSDevice.contentDescriptor(LocalIOSDevice.kt:32) at maestro.drivers.IOSDriver.contentDescriptor(IOSDriver.kt:175) at maestro.ViewHierarchy$Companion.from-c1iYVAs(ViewHierarchy.kt:28) at maestro.Maestro.viewHierarchy-prqvCes(Maestro.kt:320) at maestro.studio.DeviceScreenService$routes$1.invokeSuspend(DeviceScreenService.kt:41) at maestro.studio.DeviceScreenService$routes$1.invoke(DeviceScreenService.kt) at maestro.studio.DeviceScreenService$routes$1.invoke(DeviceScreenService.kt) at io.ktor.server.routing.Route$buildPipeline$1$1.invokeSuspend(Route.kt:116) at io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt) at io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101) at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) at io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invokeSuspend(Pipeline.kt:478) at io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt) at io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt) at io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17) at io.ktor.server.routing.Routing.executeResult(Routing.kt:174) at io.ktor.server.routing.Routing.interceptor(Routing.kt:49) at io.ktor.server.routing.Routing$Plugin$install$1.invokeSuspend(Routing.kt:124) at io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt) at io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invokeSuspend(BaseApplicationEngine.kt:123) at io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt) at io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at io.ktor.server.application.hooks.CallFailed$install$1$1.invokeSuspend(CommonHooks.kt:43) at io.ktor.server.application.hooks.CallFailed$install$1$1.invoke(CommonHooks.kt) at io.ktor.server.application.hooks.CallFailed$install$1$1.invoke(CommonHooks.kt) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89) at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264) at io.ktor.server.application.hooks.CallFailed$install$1.invokeSuspend(CommonHooks.kt:42) at io.ktor.server.application.hooks.CallFailed$install$1.invoke(CommonHooks.kt) at io.ktor.server.application.hooks.CallFailed$install$1.invoke(CommonHooks.kt) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101) at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478) at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17) at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invokeSuspend(DefaultEnginePipeline.kt:118) at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt) at io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt) at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123) at io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81) at io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101) at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77) at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478) at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt) at io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17) at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invokeSuspend(NettyApplicationCallHandler.kt:119) at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt) at io.ktor.server.netty.NettyApplicationCallHandler$handleRequest$1.invoke(NettyApplicationCallHandler.kt) at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55) at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112) at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56) at kotlinx.coroutines.BuildersKt.launch(Unknown Source) at io.ktor.server.netty.NettyApplicationCallHandler.handleRequest(NettyApplicationCallHandler.kt:37) at io.ktor.server.netty.NettyApplicationCallHandler.channelRead(NettyApplicationCallHandler.kt:29) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:61) at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:370) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.ktor.server.netty.EventLoopGroupProxy$Companion.create$lambda-1$lambda-0(NettyApplicationEngine.kt:288) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829) Suppressed: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9080 ... 98 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 97 more Caused by: java.net.ConnectException: Connection refused (Connection refused) at java.base/java.net.PlainSocketImpl.socketConnect(Native Method) at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412) at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255) at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237) at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.base/java.net.Socket.connect(Socket.java:615) at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128) at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295) ... 97 more ```

After refreshing the web app, the studio working fine.

In latest version (1.21) however, doing the same throwing the same error, but it keeps repeating infinitely and the web app never loaded.

edgarfroes commented 1 year ago

I don't want to be that guy, but can't you folks add E2E testing to test maestro itself? iOS is simply broken.

dmitry-zaitsev commented 1 year ago

@edgarfroes the challenge is that this issue is not reproducible on our machines (both Intel and M1), but we have some leads now.

Could you please check if you have anything running on port 9080 on your machine before you start Maestro (Studio or test, doesn't matter)? Maestro is using that port to communicate with iOS devices

edgarfroes commented 1 year ago

@dmitry-zaitsev there are no services running on 9080. Here's the result of running netstat -a -n | grep 'LISTEN ':

``` tcp4 0 0 127.0.0.1.5037 *.* LISTEN tcp4 0 0 *.88 *.* LISTEN tcp6 0 0 *.88 *.* LISTEN tcp4 0 0 *.5900 *.* LISTEN tcp6 0 0 *.5900 *.* LISTEN tcp4 0 0 *.22 *.* LISTEN tcp6 0 0 *.22 *.* LISTEN ```

Here's the log dump: 2023-01-27_185824.zip

dmitry-zaitsev commented 1 year ago

@edgarfroes something is preventing us form installing and launching iOS driver on your simulator on 9080 port. This could be your Simulator settings or some other software interfering on your workstation, due to that it is hard to pinpoint the issue. Anything that comes to mind by any chance?

hunzai commented 1 year ago

@dmitry-zaitsev you are right the ios driver is not getting installed on the device after I upgrade

It worked with previously with

@edgarfroes what is your CI VM configurations/ tools?

@dmitry-zaitsev I am sure you are running in CI for the cloud. Would it be possible to share the iOS VM specs? So that we can use same configs/specs to run iOS to reproduce?

amanjeetsingh150 commented 1 year ago

Hey folks, there is a confusion here. There are 2 separate issues getting discussed here which are not related to each other. The necessary fixes for both of them will be released in next versions.

  1. ConnectException what the title speaks about: That could happen if you have multiple sessions of maestro running. One of the cases being what @idrakimuhamad stated. We have a tentative fix for this one which should soon be out and we'll keep you guys updated on that.
  2. Another one where exception line is "[Unable to obtain active app id]. (https://github.com/mobile-dev-inc/maestro/issues/646)" . For this one, ensure that your 9080 port is free before running iOS tests for now to unblock.
amanjeetsingh150 commented 1 year ago

Hey folks, this should be fixed in the new version of maestro cli 1.22.1. Feel free to open issue in case you still face difficulties.

github-actions[bot] commented 1 month ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. Thank you for helping keep us our issue tracker clean!