Skip to content

ECONNRESET with android emulator #2272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Nov 28, 2016 · 27 comments
Closed

ECONNRESET with android emulator #2272

ghost opened this issue Nov 28, 2016 · 27 comments

Comments

@ghost
Copy link

ghost commented Nov 28, 2016

I'm using Atom with the atom-typescript package to edit the sample-Groceries folder. I'm on a Windows 10 machine and I'm trying to run tns livesync android --emulator --watch, which works fine. Emulator comes up and running, displays the front page of the app. I'm even able to change change the files a few times and see the emulator reload the page.

Here is what my command line looks like, with a successful change, then error:

JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
10:41:03 AM - File change detected. Starting incremental compilation...

10:41:04 AM - Compilation complete. Watching for file changes.

Executing before-prepare hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-prepare\nativescript-dev-typescript.js
Project successfully prepared (android)
Transferring project files...
Successfully transferred all files.
Applying changes...
Successfully synced application org.nativescript.groceries on device emulator-5554.
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
10:41:12 AM - File change detected. Starting incremental compilation...

Error: read ECONNRESET
    at exports._errnoException (util.js:1036:11)
    at TCP.onread (net.js:564:26)
Sending exception report (press Ctrl+C to stop)...

Any ideas to what can cause a connection reset, after several successful cycles of livesyncing? Also, where can I find the exception report mentioned in the last line?

Update: I ran tns doctor and got no errors. I turned on usage-reporting and error-reporting and the instance I ran after that lasted a long time without interruption. When I ended that and started up a new one, the new instance ended within a few minutes. I'm thinking this may be an issue with running commands too quickly after each other, but I'll keep updating this as I work.

@petekanev
Copy link
Contributor

@gbhojraj thanks for reporting this issue. I can confirm this is an actual problem as it occurred for me as well today.

@ghost
Copy link
Author

ghost commented Nov 29, 2016

Update: This happened to me again OUTSIDE livesync. I ran tns run android --emulator and I received the same ECONNRESET error after about 2 minutes of using it. I was working on Chapter 3 of the tutorial. I'm using the default emulator in the avd.

@ghost ghost changed the title ECONNRESET with livesync android emulator ECONNRESET with android emulator Nov 29, 2016
@ghost
Copy link
Author

ghost commented Nov 29, 2016

A similar issue regarding the same error was referenced in this Nativescript repo issue and was supposedly fixed in 2.4.0, but that is the version I am running. I also have tns-android at 2.4.1.

Here are the results of my log trace:

Successfully deployed on device with identifier 'emulator-5554'.
spawn: C:\Users\gibry\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "emulator-5554" "shell" "monkey" "-p" "org.nativescript.groceries" "-c" "android.intent.category.LAUNCHER" "1"
Result when throw error is false:
{ stdout: 'Events injected: 1\r\r\n## Network stats: elapsed time=14ms (0ms mobile, 0ms wifi, 14ms not connected)\r\r\n',
  stderr: '',
  exitCode: 0 }
spawn: C:\Users\gibry\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "emulator-5554" "logcat" "-c"
Result when throw error is false:
{ stdout: '', stderr: '', exitCode: 0 }
spawn: C:\Users\gibry\AppData\Local\Android\android-sdk\platform-tools\adb "-s" "emulator-5554" "logcat"
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
Error: read ECONNRESET
    at exports._errnoException (util.js:1036:11)
    at TCP.onread (net.js:564:26)
Analytics statuses:
{ TrackFeatureUsage: 0, TrackExceptions: 0 }
Trying to track exception with message 'read ECONNRESET'.
Waiting for analytics to send information. Will check in a 1000ms.

@tzraikov tzraikov added this to the 2.5.0 milestone Nov 29, 2016
@petekanev
Copy link
Contributor

Related to #2181

@petekanev
Copy link
Contributor

@gbhojraj a fix is now available in the master branch, and should soon be available in npm with the @next tag.

Please let us know if things work as expected after updating the nativescript CLI!

@ghost
Copy link
Author

ghost commented Nov 30, 2016

Still having the issue after updating and restarting my cmd with [email protected]

@valentinstoychev
Copy link

Do you see an error activity loaded inside the app before this console error is displayed?

@ghost
Copy link
Author

ghost commented Nov 30, 2016

No. Here is what my cmd looks like:

C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries>tns livesync android --watch
Executing before-prepare hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-prepare\nativescript-dev-typescript.js
Found peer TypeScript 2.1.1
Project successfully prepared (android)
Executing before-livesync hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-livesync\nativescript-angular-sync.js
Starting Android emulator with image Emulator-Api23-Default
Waiting for emulator device initialization....
Transferring project files...
Successfully transferred all files.
Applying changes...
Successfully synced application org.nativescript.groceries on device emulator-5554.
Executing before-watch hook from C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries\hooks\before-watch\nativescript-dev-typescript.js
Found peer TypeScript 2.1.1
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
1:26:21 PM - Compilation complete. Watching for file changes.

Error: read ECONNRESET
    at exports._errnoException (util.js:1036:11)
    at TCP.onread (net.js:564:26)
Sending exception report (press Ctrl+C to stop)...
C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries>tns --version
2.5.0-2016-11-30-7269

I'm running the sample groceries app, currently at chapter 3. I don't have to interact with the emulator at all for this error to be thrown.

@ghost
Copy link
Author

ghost commented Nov 30, 2016

This file is in ~/platforms/android/build/outputs/logs, so I think it's a log file from my last run. Don't know if it provides any useful information about the ending.

manifest-merger-F0-debug-report.txt

@ghost
Copy link
Author

ghost commented Nov 30, 2016

Here is my attempt at using adb logcat to catch potential errors. There was at least one error early in running the emulator, but no high priority messages near the end when tns crashed.
tns-debug.txt

@valentinstoychev
Copy link

@vchimev @tzraikov - can you please check this?

@petekanev
Copy link
Contributor

@gbhojraj thanks for providing logs, but these should be unrelated to the issue at hand. One outputs result of merging assets and the other is, well, android log with runtime debug output.

We'll investigate further, thanks for your patience!

@tzraikov
Copy link
Contributor

tzraikov commented Dec 1, 2016

@gbhojraj Thank you for those details. The ECONNRESET message appears when the server side (the app in the android simulator In this case) closes the TCP conversation abruptly. This could happen when it crashes for some reason. We are still trying to reproduce this issue. Please, could you remove the app from the simulator and try to livesync again? If the issue still reproduces, you could help by sending us the broken project (including the platforms folder).

@ghost
Copy link
Author

ghost commented Dec 1, 2016

Thanks @Pip3r4o for the explanation of the files. When the CLI crashes on ECONNRESET, the last line is Sending exception report (press Ctrl+C to stop)... and I was trying to find that.

@tzraikov Do you mean I should run the simulator first from android avd and then run the livesync command? Or that I should create a new blank project and try to run it?

Also, the project I'm using is clones from Nativescript/sample-Groceries. The only difference between my code and theirs is in the /app folder, where I sometimes use es6 syntax. I didn't mess around with any other files.

@tzraikov
Copy link
Contributor

tzraikov commented Dec 1, 2016

Follow those steps:

  1. Start the simulator with android avd
  2. Remove the installed app manually
  3. Remove the platforms folder in your project
  4. Execute tns livesync android --watch

@tzraikov
Copy link
Contributor

tzraikov commented Dec 1, 2016

@gbhojraj Please note that if your app contains errors, you will see the error screen on the simulator. However, the CLI should be functional and it will sync all changes in your code.

@ghost
Copy link
Author

ghost commented Dec 1, 2016

Thanks @tzraikov . I'm still getting the error. I've seen errors on the simulator before, but not in connection with ECONNRESET. I've seen no errors regarding that.

I'm still getting the error, even if I wipe user data (and the app) from the emulator. I've pushed this project to a new repo: https://github.com/gbhojraj/sample-Groceries

@tzraikov
Copy link
Contributor

tzraikov commented Dec 2, 2016

@gbhojraj I tested the project from your repo. After commenting some lines of code it compiles and the livesync works as expected. It is very strange that you experience this kind of error, our @next version contains the following code which filters such messages:
https://github.com/NativeScript/nativescript-cli/blob/master/lib/services/livesync/android-device-livesync-service.ts#L112

Could you post again the exact message that you get? I want to be sure that we are talking about the same issue.

In some scenarios npm on Windows caches its packages and that is why I suggest the following:

  1. uninstall nativescript cli by executing npm uninstall -g nativescript
  2. clear the npm cache: npm cache clean
  3. install the latest CLI npm install -g nativescript
  4. remove the platforms folder in your project
  5. execute tns run android --emulator
  6. try tns livesync android --emulator --watch

@ghost
Copy link
Author

ghost commented Dec 2, 2016

After following the steps you outlined, I tried running the project again. It seemed like it was working, but after a few trials (stopping tns and running it again), I started seeing the error again. I'll attach a TXT with the full output of my command, but here's the error specifically:

Error: read ECONNRESET
    at exports._errnoException (util.js:1036:11)
    at TCP.onread (net.js:564:26)
Sending exception report (press Ctrl+C to stop)...
C:\Users\gibry\Documents\Sandbox\NativeScript\sample-Groceries>

My problem isn't that livesync isn't restarting on malformed code. It's that both tns run and tns livesync sometimes randomly throw ECONNRESET errors even without input from me, whether that's changing the code or clicking an empty button on the emulator. And when livesync throws this error, it stops the livesync process completely. After the error is thrown and tns disconnects, the project is still viewable and usable in the emulator.

I didn't think it would be a problem with the project, because it's just a sample project. I'll try running another sample project. But I don't know what on my system could be interfering with the connection between the CLI and AVD.

@ghost
Copy link
Author

ghost commented Dec 4, 2016

(Sorry, just realizedd I didn't attach the cmd output before)
tns-run.txt

@ghost
Copy link
Author

ghost commented Dec 5, 2016

Update: It seems if I launch the emulator from android avd and then connect with tns livesync android --watch after it's fully loaded, I don't have any connection issues.

@tzraikov
Copy link
Contributor

tzraikov commented Dec 6, 2016

@gbhojraj Thanks for this information. We observed issues with some versions of the latest android emulators. Please, could you upgrade your Android SDK and emulators to the latest version. If this doesn't help, send us your project in a broken state (including the platforms folder). This will help us to investigate further.

@tzraikov tzraikov removed this from the 2.5.0 milestone Dec 27, 2016
@ThomasPetrak
Copy link

gbhojraj - thanks! Had exactly the same issue even with the basic HelloWorld project and the workaround you suggested worked for me (launch the emulator from android avd and then connect with tns livesync android --watch).

@santosgabriel
Copy link

Same error here and same solution.

Start android emulator with android avd selecting the one created by the NativeScript install (I have more emulators) and start the project with tns run android --watch.

@Cae2
Copy link

Cae2 commented Mar 21, 2017

also, same error and same solution. thanks

@james4han
Copy link

Thanks @gbhojraj for continuing pursuit to solve this issue.
Thanks @tzraikov .
Had this same issue and trying to get over this for quite some time and did same steps to resolve issue.

Just need to know one thing though.. Can we make full fledged e-commerce app on this platform or more work needs to be done to make this platform to use on commercial basis for non-stopping development.

@gustavodemorais
Copy link

gustavodemorais commented Oct 22, 2017

Almost a year later and..

Same problem, same solution described by @gbhojraj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

11 participants