Skip to content

Cannot set property 'socket' of null #3818

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
tsonevn opened this issue Aug 14, 2018 · 32 comments
Closed

Cannot set property 'socket' of null #3818

tsonevn opened this issue Aug 14, 2018 · 32 comments
Assignees
Milestone

Comments

@tsonevn
Copy link
Contributor

tsonevn commented Aug 14, 2018

From @RoyiNamir on August 12, 2018 9:42

After upgrading our project to 4.2 , we've experiencing socket connections problems to a real device when tns run android

Worth to mention that tns run android does work with emulators ( both Geny & AVD) , but it doesn't work with real devices ( my Galaxy s8+ and a colleague's Galaxy s8 , non rooted regular device)

C:\projects-web-storm\digital\dsapp1>tns info
√ Getting NativeScript components versions information...
√ Component nativescript has 4.2.1 version and is up to date.
√ Component tns-core-modules has 4.2.0 version and is up to date.
√ Component tns-android has 4.2.0 version and is up to date.
× Component tns-ios is not installed.

When tns run android :

we get :

Unable to apply changes on device: ce031713a8d0149e0d. Error is: Socket connection timeouted..
Executing after-watch hook from C:\projects-web-storm\digital\dsapp1\hooks\after-watch\nativescript-dev-sass.js
Executing after-watch hook from C:\projects-web-storm\digital\dsapp1\hooks\after-watch\nativescript-dev-typescript.js
Stopping tsc watch
Executing after-watch hook from C:\projects-web-storm\digital\dsapp1\hooks\after-watch\nativescript-dev-webpack.js
TypeError: Cannot set property 'socket' of null
    at Timeout.tryConnect [as _onTimeout] (C:\Users\royin\AppData\Roaming\npm\node_modules\nativescript\lib\services\livesync\android-livesync-tool.js:298:51)
    at ontimeout (timers.js:482:11)
    at tryOnTimeout (timers.js:317:5)
    at Timer.listOnTimeout (timers.js:277:5)

--> Video showing the problem <--

The app IS installed but not invoked. ( it used to work) before upgrade.
We have to tap the launch icon in order to see the app running
PackageID is the same in all files ( manifest / packagejson)

BTW - if you want a real project that produces it , I can send privately.


Windows machine , Android , Antivirus & firewall is disabled , uninstalled App from device.

Copied from original issue: NativeScript/NativeScript#6180

@tsonevn
Copy link
Contributor Author

tsonevn commented Aug 14, 2018

From @iguissouma on August 12, 2018 14:35

I'm also getting same error after updating to nativescript 4.2 and just running a new created project.

@tsonevn
Copy link
Contributor Author

tsonevn commented Aug 14, 2018

From @dtopuzov on August 12, 2018 16:28

Hi @iguissouma,

Can you please specify device model and Android version of the device?

@tsonevn
Copy link
Contributor Author

tsonevn commented Aug 14, 2018

From @iguissouma on August 12, 2018 17:11

Hello @dtopuzov ,

I'm facing the problem on device and emulator.
Emulator: Nexus 5X API 27
Device: Asus Zenfone 2 - Android version 6.0.1

@tsonevn
Copy link
Contributor Author

tsonevn commented Aug 14, 2018

From @opsional on August 12, 2018 23:1

I'm to, on Android 4.4.2 (real device), but after re-run app works.

@tsonevn
Copy link
Contributor Author

tsonevn commented Aug 14, 2018

Hi @RoyiNamir,
Can you try to clear the npm cache via npm cache clear delete platforms, node_modules, hooks folders and package-lock.json file? Uninstall the app from the device and rebuild it with tns run android command.

@tsonevn
Copy link
Contributor Author

tsonevn commented Aug 14, 2018

From @RoyiNamir on August 13, 2018 8:10

Hi @tsonevn
Sure.

Here is the folder after delete ( created a new folder named tsonevn):

image

image

run npm i

tns run android :

C:\projects-web-storm\digital\r\tsonevn>tns run android
Skipping node_modules folder! Use the syncAllFiles option to sync files from this folder.       Searching for devices...
npm WARN deprecated [email protected]: Switch to the `bfj` package for fixes and new features!
npm WARN deprecated [email protected]: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated [email protected]: Package no longer supported. Contact [email protected] for more info.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN notice [SECURITY] lodash has the following vulnerability: 1 low. Go here for more details: https://nodesecurity.io/advisories?search=lodash&version=3.10.1 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.

> [email protected] install C:\projects-web-storm\digital\r\tsonevn\node_modules\node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.9.3/win32-x64-57_binding.node
Download complete  ] - :
Binary saved to C:\projects-web-storm\digital\r\tsonevn\node_modules\node-sass\vendor\win32-x64-57\binding.node
Caching binary to C:\Users\royin\AppData\Roaming\npm-cache\node-sass\4.9.3\win32-x64-57_binding.node

> [email protected] postinstall C:\projects-web-storm\digital\r\tsonevn\node_modules\node-sass
> node scripts/build.js
p
Binary found at C:\projects-web-storm\digital\r\tsonevn\node_modules\node-sass\vendor\win32-x64-57\binding.node
Testing binary
Binary is fine
s
> [email protected] postinstall C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-angular
> node postinstall.js
s:
/r
> [email protected] postinstall C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-dev-sass
> node postinstall.js
pmjs
org
> [email protected] postinstall C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-dev-typescript
> node postinstall.js
/co
Adding 'es6' lib to tsconfig.json...
Adding 'dom' lib to tsconfig.json...
Adding 'es2015.iterable' lib to tsconfig.json...
Adding tns-core-modules path mappings lib to tsconfig.json...
Project already targets TypeScript ~2.7.2
z
> [email protected] postinstall C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-dev-webpack
> node postinstall.js

The current project contains a webpack.config.js file located at C:\projects-web-storm\digital\r\tsonevn\webpack.config.js that differs from the one in the new version of the nativescript-dev-webpack plugin located at C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-dev-webpack\templates\webpack.angular.js. Some of the plugin features may not work as expected until you manually update the webpack.config.js file or automatically update it using "./node_modules/.bin/update-ns-webpack --configs" command.
Dev dependency: @angular/compiler-cli already added. Leaving version: ~6.1.0-beta.1
retr
NativeScript Webpack plugin was successfully added.
You can now bundle your project by passing --bundle flag to NativeScript CLI commands:
    - tns build android --bundle
    - tns build ios --bundle
    - tns run android --bundle
    - tns run ios --bundle
You can also pass the "--env.uglify" flag to use UglifyJS for minification.
For more information check out https://docs.nativescript.org/tooling/bundling-with-webpack#bundling.

Some dependencies have already been added. If you want to force update them, please run "node_modules/.bin/update-ns-webpack".


> [email protected] postinstall C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-plugin-firebase
> node postinstall-hooks.js && node scripts/postinstall.js

NativeScript Firebase Plugin Installation
Config file exists (firebase.nativescript.json)
Successfully created iOS (Pod) file.
Successfully created Android (include.gradle) file.
Install google-service.json copy hook.
Install firebase-build-gradle hook.
Writing 'firebase-build-gradle.js' to ../..//hooks/after-prepare
Firebase post install completed. To re-run this script, navigate to the root directory of `nativescript-plugin-firebase` in your `node_modules` folder and run: `npm run config`.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] requires a peer of webpack@^3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 1472 packages in 71.011s
Executing before-liveSync hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-liveSync\nativescript-angular-sync.js
Executing before-watchPatterns hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-watchPatterns\nativescript-dev-sass.js
Executing before-watchPatterns hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-watchPatterns\nativescript-dev-typescript.js
Executing before-watchPatterns hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-watchPatterns\nativescript-dev-webpack.js
Executing before-watch hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-watch\nativescript-dev-sass.js
Found peer node-sass
Executing before-watch hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-watch\nativescript-dev-typescript.js
Found peer TypeScript 2.7.2
Executing before-watch hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-watch\nativescript-dev-webpack.js
Copying template files...
Platform android successfully added. v4.2.0
Executing before-shouldPrepare hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-shouldPrepare\nativescript-dev-webpack.js
Executing before-prepare hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-prepare\nativescript-dev-sass.js
Hook skipped because either bundling or livesync is in progress.
Executing before-prepare hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-prepare\nativescript-dev-typescript.js
Hook skipped because either bundling or livesync is in progress.
Executing before-prepare hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-prepare\nativescript-plugin-firebase.js
Preparing project...
Executing before-prepareJSApp hook from C:\projects-web-storm\digital\r\tsonevn\hooks\before-prepareJSApp\nativescript-dev-webpack.js
Successfully prepared plugin @teammaestro/nativescript-svg for android.
Successfully prepared plugin nativescript-angular for android.
Successfully prepared plugin nativescript-appavailability for android.
Successfully prepared plugin nativescript-calendar for android.
Successfully prepared plugin nativescript-camera for android.
Successfully prepared plugin nativescript-fingerprint-auth for android.
Successfully prepared plugin nativescript-geolocation for android.
Successfully prepared plugin nativescript-imagepicker for android.
Successfully prepared plugin nativescript-iqkeyboardmanager for android.
Successfully prepared plugin nativescript-loading-indicator for android.
Successfully prepared plugin nativescript-ng-shadow for android.
Successfully prepared plugin nativescript-pdf-view for android.
Successfully prepared plugin nativescript-phone for android.
Successfully prepared plugin nativescript-plugin-firebase for android.
Successfully prepared plugin nativescript-screen-orientation for android.
nativescript-swift-3.0 is not supported for android.
Successfully prepared plugin nativescript-swift-3.0 for android.
Successfully prepared plugin nativescript-textinputlayout for android.
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin nativescript-toast for android.
Successfully prepared plugin nativescript-tslib for android.
Successfully prepared plugin nativescript-ui-listview for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin nativescript-intl for android.
Successfully prepared plugin nativescript-permissions for android.
Successfully prepared plugin nativescript-ui-core for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Built aar for nativescript-calendar
Built aar for nativescript-ng-shadow
Built aar for nativescript-phone
Project successfully prepared (Android)
Executing after-prepare hook from C:\projects-web-storm\digital\r\tsonevn\hooks\after-prepare\firebase-build-gradle.js
Configure firebase
Executing after-prepare hook from C:\projects-web-storm\digital\r\tsonevn\hooks\after-prepare\firebase-copy-google-services.js
Copy C:\projects-web-storm\digital\r\tsonevn\app\App_Resources\Android\google-services.json to C:\projects-web-storm\digital\r\tsonevn\platforms\android\google-services.json.
Note: Some input files use or override a deprecated API.digital\r\tsonevn\hooks\after-prepare\nativescript-dev-sass.js
Note: Recompile with -Xlint:deprecation for details.

Project successfully built.
Installing...
Successfully installed on device with identifier 'ce031713a8d0149e0d'.
Unable to apply changes on device: ce031713a8d0149e0d. Error is: Socket connection timeouted..
Executing after-watch hook from C:\projects-web-storm\digital\r\tsonevn\hooks\after-watch\nativescript-dev-sass.jstion\platforms\android\
Executing after-watch hook from C:\projects-web-storm\digital\r\tsonevn\hooks\after-watch\nativescript-dev-typescript.js
Executing after-watch hook from C:\projects-web-storm\digital\r\tsonevn\hooks\after-watch\nativescript-dev-webpack.js
TypeError: Cannot set property 'socket' of null
    at Timeout.tryConnect [as _onTimeout] (C:\Users\royin\AppData\Roaming\npm\node_modules\nativescript\lib\services\livesync\android-livesync-tool.js:298:51)XECUTING [7s]dency: C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-plugin-firebase\platforms\andr
    at ontimeout (timers.js:482:11)
    at tryOnTimeout (timers.js:317:5)cy: C:\projects-web-storm\digital\r\tsonevn\node_modules\nativescript-ui-listview\platforms\android\
    at Timer.listOnTimeout (timers.js:277:5)

@farfromrefug
Copy link
Contributor

@Fatme @tsonevn I am still seeing this with 4.2.2
The first run works. But then if I run it again it fails.
In my logcat I keep on seeing this:
failed to connect to socket 'localabstract:org.nativescript.apps-livesync': Connection refused

I am getting this almost all the time :s I can't even update my apps.
Happening on emulator and device

@RoyiNamir
Copy link

RoyiNamir commented Aug 16, 2018

@farfromrefug remove the dash from :org.nativescript.apps-livesync and make a capital letter in org.nativescript.Appslivesync

See this

#3819 (comment)

@farfromrefug
Copy link
Contributor

@RoyiNamir and where should I do that. I can't This I not the app name! The app name is simply org.nativescript.apps
I guess the -livesync is added by the CLI

@RoyiNamir
Copy link

@farfromrefug can you paste your android manifest file?

@farfromrefug
Copy link
Contributor

manifest ;)

@RoyiNamir
Copy link

RoyiNamir commented Aug 16, 2018

@farfromrefug do you extend an activity ?

@farfromrefug
Copy link
Contributor

no I simply run the ui test app :D working on the framework

@RoyiNamir
Copy link

@farfromrefug if that's the case then i guess i dont know...

@nikopolv
Copy link

I'm experiencing the exact same problem. Couple of times I'v got the livesync/debug to work, but most of the times it installs the app and timeouts.

@RoyiNamir
Copy link

@nikopolv what's your activity name in manifest ? did you read the discussion ^ ?

@nikopolv
Copy link

I did yea. I also tried com.company.android.app, com.company.AndroidApp, Com.Company.AndroidApp
The same results.

Project successfully built.
Installing...
Successfully installed on device with identifier 'xxxxx'.
Unable to apply changes on device: xxxxx. Error is: Socket connection timeouted..
Executing after-watch hook from C:...\hooks\after-watch\nativescript-dev-typescript.js
Stopping tsc watch
TypeError: Cannot set property 'socket' of null
at Timeout.tryConnect [as _onTimeout] (C:....\npm\node_modules\nativescript\lib\services\livesync\android-livesync-tool.js:298:51)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)

@RoyiNamir
Copy link

@nikopolv the rule (after 4.2.2) is *.*.[capital]*

Also did you remove platform and then add ?

@DimitarTachev
Copy link
Contributor

Hi @farfromrefug , @RoyiNamir, @nikopolv,

This exception should not be caused by your app ids. We don't have a rule for a capital letter there. The starting capital letter is required only for the class name of the custom activities and there aren't any changes there. In other words, org.nativescript.apps is a perfectly valid app id and the sample is working correctly with NativeScript 4.2.2 on our side.

The real issue looks like the above-mentioned failed to connect to socket 'localabstract:org.nativescript.apps-livesync': Connection refused exception. @farfromrefug @nikopolv, could you run tns run android --log trace and update us back with the detailed log from the problematic executions? I also suggest you make a clean copy of the org.nativescript.apps app in order to avoid getting some strange errors caused by a parcial app state after the experiments.

@RoyiNamir, thanks for helping with that, however, the regex change in 4.2.2 is just allowing the usage of capital letters in the packages of the custom activities (e.g. using org.nativescript.apps/org.MyCoolApp.MyCoolActivity instead of the recommended org.nativescript.apps/org.mycoolapp.MyCoolActivity) and I don't belive this change is related to the issues of @farfromrefug and @nikopolv.

@RoyiNamir
Copy link

RoyiNamir commented Aug 22, 2018

@DimitarTachev Thanks for clarifying. However , I've never mentioned app id. I always asked about activity name ;-)

However , it might be that i've confused (miscommunication) appID vs activity name .

BTW - as you can see in the OP's log , there is a timeout socket , and my( spcific) problem was activity name named xxx.myApp.Something ( problematic A).
After lowercasing it , all errors gone ( in my case).

@DimitarTachev
Copy link
Contributor

@RoyiNamir, the app id clarification was related to the "org.nativescript.apps-livesync" comments above. That's just a socket related string containing the app id concatenated with "-livesync" and it's not causing the exception.

Regarding your specific problem, you should be also able to use xxx.myApp.Something with NativeScript 4.2.2 but as I already mentioned, the lowercase package name is the recommended approach :)

We will need more info from @farfromrefug and @nikopolv in order to further investigate their issues as I don't believe thay are related to custom activities with some strange naming. I hope we will get more details for the failed to connect to socket 'localabstract:org.nativescript.apps-livesync': Connection refused error from their trace logs.

@manojdcoder
Copy link

@tsonevn This also happens when the nativescript id in package.json is different from one in the manifest / gradle file. I had to keep them different as I wanted different package names for iOS & Android.

@aaayushsingh
Copy link

Still getting this after upgrading to 4.2.3, plus a new error as well see #3851

@ghost
Copy link

ghost commented Sep 22, 2018

@tsonevn Im still getting the error after upgrading to 4.2.4. Any workaround for this issue?

Unable to apply changes on device: HBAXB7661532BHJ. Error is: Socket connection timeouted..
Executing after-watch hook from E:\frontend\yudabands-m-2\hooks\after-watch\nativescript-dev-typescript.js
Stopping tsc watch
Executing after-watch hook from E:\frontend\yudabands-m-2\hooks\after-watch\nativescript-dev-webpack.js
Executing after-watch hook from E:\frontend\yudabands-m-2\hooks\after-watch\nativescript-dev-typescript.js
Executing after-watch hook from E:\frontend\yudabands-m-2\hooks\after-watch\nativescript-dev-webpack.js

@NathanWalker
Copy link
Contributor

I just started getting this error as well today with Android - very strange 🤔

@tsonevn
Copy link
Contributor Author

tsonevn commented Oct 8, 2018

Hi, @jannotabamo @NathanWalker,
Can you run the project with --log trace flag (tns run <platform_name> --log trace) and send us the full log with the error? Also, can you provide more info, if this problem happens consistently and whether this issue appears only on a specific device or emulators?
Meanwhile, try to clear up the project by deleting platforms, node_modules and hooks folders and check if you will be able to recreate the problem.

@aaayushsingh, can you upgrade to NativeScript CLI 4.2.4 and check if the problem will be resolved on your side?

@shiv19
Copy link
Member

shiv19 commented Oct 8, 2018

@tsonevn @DimitarTachev
Hope this log file helps. 🤞🏻
log.txt

@NathanWalker
Copy link
Contributor

Thanks @shiv19 hopefully @tsonevn that log helps 🤞

@KristianDD
Copy link
Contributor

Hi @shiv19 ,
I have doubled the time we wait for the socket connection to be established in the master branch. You can try the fix with the next version. Just install CLI like this npm i -g nativescript@next.

If that doesn't help please check if the application is started on the device, before the message appears. If the application is not started at all unify the values of
1 nativescript.id key in package.json
2 applicationId in app/App_Resources/Android/app.gradle
3 appId in app/App_Resources/Android/settings.json(this one might not exist if you don't use NS Sidekick)
It they are different the CLI can't work properly.

@KristianDD KristianDD reopened this Oct 10, 2018
@shiv19
Copy link
Member

shiv19 commented Oct 10, 2018

@nwalker
See that 3rd point in previous reply.
That explains how we have settings.json in that project.
I used sidekick on that project recently when we changed the icons.

@shiv19
Copy link
Member

shiv19 commented Oct 12, 2018

@KristianDD
Thank you! Looks like that has solved the issue. I don't see that problem anymore.

@rosen-vladimirov
Copy link
Contributor

Hey everyone,
We've merged an improvement in the error message shown by CLI in this case that suggests some ideas what might cause the error. The new message is available in CLI's rc version (npm i -g nativescript@rc) and should be released with CLI 6.3.3 version.

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