Android virtual device and backend calls


#1

Hi i would like to connect from virtual device app to rest service that i started in previous script step (simple nodejs app with rest endpoint).
I tried to connect with 10.0.2.2 but i get socket timeout after 10 seconds.

Is it possible to connect to app started in another step? Is there any solition for that?


#2

According to


localhost should work, but it is not…
any help?


#3

Hy there! localhost is accessible, but if you were to start up a node server, it would hold up the build until it runs, so you would time out as well.


#4

i run it wit forever tool, here is the script:

npm install -g npm
sudo apt-get install nodejs
git clone https://xxxxxxxx.git
npm install
npm install forever --global
forever start app.js

then UI tests are running and cannot access localhost, but after virtual device ui tests i have another script step which do simple localhost curl request and it works like a charm…


#5

@fehersanyi-bitrise maybe i should expose node app host or port somehow?


#6

@bitrise-support
anybody here who can help me? :slight_smile:


#7

Hello there! could you link me the build’s url please?


#8

sure, here it is:

https:// app.bitrise.io/ build/ 621b6e12246ceb52


@fehersanyi-bitrise thank you for your interest :slight_smile:


#10

@fehersanyi-bitrise did you have a chance to check my build? :frowning:


#11

Hello there! sorry for the long wait, the thing is, there is nothing in the logs, so I am not really able to say anything. The test just fails.
@viktorbenei could you look at it if you have time?


#12

please check logs here:
https://storage.googleapis.com /bitrise-addon-ftl-prod-bucket/android-tests/621b6e12246ceb52/results/Nexus6-21-en-portrait/logcat?Expires=1540574826&GoogleAccessId=bitrise-addon-ftl-prod-serv-ac%40bitrise-addon-ftl-prod.iam.gserviceaccount.com&Signature=bjo%2B7ciUxPv8j6APfqFfgBMz%2FCIxjn%2FQsSRZmfl%2F9hU7Z7HemvNnfbnbf9MmT%2Fs8mWQjCPFmVPASZWJXrbp9YCpwoYZZGz0UivL9%2FoHebgzXipKA95c0ZJMv%2B%2Br%2BuJd67tL7z70yzS85Uzu00SJ7fcYj0CErYCvh1KoYKhmo7VLTh3k5Wno7Qm1dHiLA79CWXZJJ3qMs0ij0x5X%2Bc3CrchppgcB7TfibLqy4P1Ve8QBw4P20yfB%2F%2BHBUqT9EwaoO78UoPyN5LrXga9oy0cPcA30x5l01dm1IRv8B1f0b9ASsHwV6QQecuZzbPojDpeqnqJaPnFU6ryBHO6T1el2AAw%3D%3D

you can find there:
10-09 00:19:33.998: E/BaseNetworkViewModel(7322): Error: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:5678 ; cause: Failed to connect to localhost/127.0.0.1:5678 [null]
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): io.moia.communication.RequestErrorException: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:5678
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.communication.extension.ThrowableKt.toRequestError(Throwable.kt:20)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.driver.mock.TestDmaClient$getDriver$1.apply(TestDmaClient.kt:29)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.driver.mock.TestDmaClient$getDriver$1.apply(TestDmaClient.kt:21)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleResumeNext$ResumeMainSingleObserver.onError(SingleResumeNext.java:73)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.observable.ObservableSingleSingle$SingleElementObserver.onError(ObservableSingleSingle.java:93)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onError(BodyObservable.java:72)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:56)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Observable.subscribe(Observable.java:12084)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Observable.subscribe(Observable.java:12084)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Single.subscribe(Single.java:3433)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleResumeNext.subscribeActual(SingleResumeNext.java:39)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Single.subscribe(Single.java:3433)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleZipArray.subscribeActual(SingleZipArray.java:64)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Single.subscribe(Single.java:3433)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleDelayWithCompletable$OtherObserver.onComplete(SingleDelayWithCompletable.java:70)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.disposables.EmptyDisposable.complete(EmptyDisposable.java:68)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.completable.CompletableEmpty.subscribeActual(CompletableEmpty.java:27)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Completable.subscribe(Completable.java:2171)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleDelayWithCompletable.subscribeActual(SingleDelayWithCompletable.java:36)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Single.subscribe(Single.java:3433)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:579)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:261)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:226)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.driver.test.steps.BaseSteps$setUp$immediate$1$createWorker$1.execute(BaseSteps.kt:63)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.schedule(ExecutorScheduler.java:143)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.schedule(ExecutorScheduler.java:159)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Scheduler.scheduleDirect(Scheduler.java:204)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.driver.test.steps.BaseSteps$setUp$immediate$1.scheduleDirect(BaseSteps.kt:59)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Scheduler.scheduleDirect(Scheduler.java:180)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleSubscribeOn.subscribeActual(SingleSubscribeOn.java:37)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Single.subscribe(Single.java:3433)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.internal.operators.single.SingleObserveOn.subscribeActual(SingleObserveOn.java:35)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Single.subscribe(Single.java:3433)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.reactivex.Single.subscribe(Single.java:3419)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.driver.ui.main.BaseUserDataViewModel.fetchData(BaseUserDataViewModel.kt:90)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.driver.ui.main.DashboardFragment.onActivityCreated(DashboardFragment.kt:117)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2355)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1451)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2596)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2383)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2338)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2245)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:382)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.v4.app.FragmentActivity.onResume(FragmentActivity.java:488)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.driver.ui.main.MainActivity.onResume(MainActivity.kt:98)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1241)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.support.test.runner.MonitoringInstrumentation.callActivityOnResume(MonitoringInstrumentation.java:699)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.Activity.performResume(Activity.java:6019)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2940)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2982)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.ActivityThread.access$800(ActivityThread.java:144)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.os.Handler.dispatchMessage(Handler.java:102)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.os.Looper.loop(Looper.java:135)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at android.app.ActivityThread.main(ActivityThread.java:5221)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at java.lang.reflect.Method.invoke(Native Method)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at java.lang.reflect.Method.invoke(Method.java:372)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): Caused by: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:5678
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:165)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:213)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at io.moia.communication.ClientFactory$httpClient$1.intercept(ClientFactory.kt:80)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.RealCall.execute(RealCall.java:77)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:42)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): … 59 more
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): Caused by: java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 5678) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at libcore.io.IoBridge.isConnected(IoBridge.java:238)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at libcore.io.IoBridge.connectErrno(IoBridge.java:171)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at libcore.io.IoBridge.connect(IoBridge.java:122)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at java.net.Socket.connect(Socket.java:882)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.platform.AndroidPlatform.connectSocket(AndroidPlatform.java:73)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:245)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): … 84 more
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): Caused by: android.system.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
10-09 00:19:33.999: E/BaseNetworkViewModel(7322): at libcore.io.IoBridge.


#13

@moia-wojtek Hy! so the problem is, that you want to connect through localhost, but the virtual device runs on firbase. so there is no localhost there :confused:


#14

Is there any possibility to connect from virtual device to my started app on bitrise?


#15

you could get the vm-s IP adress in a script step and save it to a variable with envman. then give that to the test.


#16

will try, thx


#17

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.