Can I “force” the Android Simulator to always use the same port?

◇◆丶佛笑我妖孽 提交于 2021-01-01 08:50:23

问题


I am trying to do NativeScript development on an Azure virtual box. The installation of the NativeScript development environment has been completed successfully, as I do not have any issues when I am running the

>tns doctor

command:

Once I try to run my application:

>tns run android --bundle

I see that it is successfully installed on the device identified as 'emulator-5554' but then this error pops up:

Unable to apply changes on device: emulator-5554. Error is: connect ECONNREFUSED 127.0.0.1:50232.

Here is a screenshot of my VS Code Terminal window:

It does not matter whether I start the emulator via VS Code or in Android Studio, via the AVD Manager. The same error occurs. It's just the port on the localhost (127.0.0.1) that is different.

I can see the emulator running, but it stays with a blank screen, without showing my application:

Now, since that is an Azure box, IT has all kinds of restrictions on it. All the ports are locked down, but I can get them to open one for my needs. The problem is that I do not know which one to ask to be opened. As I said, every time the emulator is restarted or accessed, the port in the error (ECONNREFUSED 127.0.0.1:50232) is different.

Anyone else has faced this issue and is there an easy solution? I was hoping that maybe there is a way to launch the emulator and have it listen to the same port always. Can that be achieved?

TIA, Eddie

Edit [Feb. 12, 2020] One of my IT friends has created a new inbound port rule on that server:

and now I do not get that error anymore. Instead, I get a different error. Maybe it's not an error per se, but the application does not start on the emulator which appears to run on its own:

Does anyone have a suggestion for this one?

来源:https://stackoverflow.com/questions/60173762/can-i-force-the-android-simulator-to-always-use-the-same-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!