Remote debug node.js app, Chrome DevTools inspected device is missing - node.js

Steps to reproduce:
1. I running node.js (node#12.14.0) application on remote server (Ubuntu) with
> node --inspect app.js
Debugger listening on ws://127.0.0.1:9229/12345678-1234-1234-1234-123456789
2. On local (Windows 10) configured the SSH tunnel
On click "open" I see, where I input my password
Using username "user".
user#site.com's password:
_
3. Configured the Chrome (URI chrome://inspect/#devices) target discovery settings
4. Finally I see no devices on Remote Target
But expecting something like this
5. netstat -a -n | grep 9221 on the server returns
What I doing wrong? How do I get the target?
Similar topics:
1. How to debug remote node.js app using chrome devtools
2.

The following worked for me
P.1 Run node.js app with root user
> node --inspect-brk app.js
P.2 For tunneling used Windows PowerShell with following line
ssh -N -L 9221:localhost:9229 root#site.com

In Discover network target add 127.0.0.1:9229 instead of the localhost:9229

Related

How do I automatically start a node/express app (with pm2), having node installed using software collections (scl), on CentOS7

1. Summarize the problem
I would like for a node/express app.js to listen on a port 3000, on container startup.
I created a CentOS 7 Docker container, installed the software collections (SCL) repo, and then installed node.
I can now enable node with:
scl enable rh-nodejs10 bash, and so I did, and then installed express (globally), and pm2 (globally), and can successfully run a minimal express app listening on port 3000 with commands I run at the command line.
I put scl enable rh-nodejs10 bash in my .bash_profile (of a user I created named: www - because I do not want root running the web server).
In fact, I will be building a rootless container (buildah), next after this, so there will be no 'root' user at all for security concerns.
Now on container startup I want to have the web server start automatically, and be able to get a response from: http://localhost:3000 (hello world).
The problem is that on container startup, node is not enabled for any user until a shell is invoked to enable it.
2. Provide background including what you've already tried
I have searched the web for a solution of using node, express, pm2 in conjunction with CentOS 7 software collections and have found no solution.
Please only reply if you have actually tried the solution your recommend, and have it working, otherwise it most likely will not work.
systemd needs to:
1. enable node
2. run pm2 start app
I tried putting both in a shell, but when you enable node, you are then put in a sub-shell and cannot script any additional commands.
3. show some code
scl enable rh-nodejs10 bash
4. Describe expected and actual results including any error messages
I expect the node/express server to listen on port 3000 on container startup.
I have node running on reboot on RHEL 7 by using scl-utils/scl_source technique found here
$ cat /etc/profile.d/enablenodejs.sh
#!/bin/bash
source scl_source enable rh-nodejs10

remote server node debug,node --inspect is not hitting the break point in chrome inspect dev tool

my nodejs (node version v10.5.0) server is runnig on 159.65.151.135:3000
I have the ssh tunneling from my local windows machine to server as ssh -L 9229:127.0.0.1:9229 user#159.65.151.135 -v
but node --inspect app.js is not hitting the breakpoint in chrome://inspect Devtool
Please help in resolving the issue
steps that I did
execute the command ssh -L 9229:127.0.0.1:9229 user#159.65.151.135
-v in CMD
open the server console and start node server with the command node --inspect app.js
open chrome and goto chrome://inspect, check the Remote Target link and click to open the Devtool
Put breakpoints in the desired locations by opening the source file by Ctr+P
in chrome load the url of my nodejs app , ie 159.65.151.135:3000
But for any action, breakpoint is not getting hit. I have tried with node --inspect-brk app.js, only the first line will get paused, after that no breakpoint execution.

Connecting to Localhost on Mac from Another Mac: Websocket Issues?

I have a node.js web app running on http://localhost:3000/ on my iMac. I am able to log on to that web app from Chrome on my MacBook using the Wi-Fi IP address of my iMac (found in System Preferences->Network) and the port my web app is running on:
http://10.0.0.37:3000
When using this technique, is there any reason why a websocket would fail in calling a service on a distant server?
Thanks in advance to any thoughts!
It turns out nothing was wrong with websockets. The camera on my MacBook was deactivated for some reason, and that was causing errors from the service I was accessing. I was able to reactivate the camera using instructions from this page:
Quit all apps that you are trying to use with the Camera > Open
Terminal (find in /Applications/Utilities) > copy and paste the
following command then hit the Enter key > Type administrator password
hit Enter.
sudo killall VDCAssistant
if still at the terminal, issue the following command:
sudo killall AppleCameraAssistant

How to run `OpenFin Process Manager`

Refer to https://github.com/openfin/process-manager
Based on the README.md, I have done the following steps:
npm install
node server
I am able to see the following message from terminal(windows 7)
$ node server
Express server listening on port 5040
How do I launch the application?
I have tried to point to the localhost:5040 through chrome browser and ONLY see three tabs 'Processes', 'Cache', 'Logs' without any information.
How can I fix the issues?
npm i -g openfin-cli
openfin -l -c http://localhost:5040/app_local.json
The server script is running a local express server that hosts an OpenFin enriched web app so all you need to do it launch it on OpenFin, which in the case above we are doing with the CLI.
You can also use a node module to launch i.e. here

ReferenceError: Can't find variable: __fbBatchedBridge

Using just the default code from react-native init AwesomeProject, when I run the app I get the 'ReferenceError: Can't find variable: __fbBatchedBridge (line 1 in the generated bundle)'.
And, when I 'Reload JS', the app just has the white background rather than any 'hello world' views. I haven't touched any of the code from the init.
Any ideas how to resolve the error?
Screenshot (click to view full size):
Using:
Ubuntu 15.10, 64-bit
Node.js v5.3.0
reactive-native v0.1.7
Nexus 5X, API 6.0.1
I generally see this when the packager hasn't started. Ensure that is running by running react-native start
I had the same issue while using Visual Studio Android Emulator. When the red screen shows up type in the command line
adb shell input keyevent 82
This will trigger the shake event and launch the dev menu
Then hit Dev Settings > Debug server host & port for device and enter <your ip adress>:8081. If for some reason you cannot type in the field you can trigger the text action in the command line by using
adb shell input text <your ip adress>:8081
i solved it using this command
adb reverse tcp:8081 tcp:8081
Thank you rmevans9 and Anonsage for your answers!
I am using HTC One on Ubuntu and there is no menu option, anyway this is the summary of the answers that worked for me:
Create the project
$ react-native init MyProject
$ cd MyProject/
In first console tab run and leave it running as you develop (react-native start alternative):
$ npm start
In second console tab compile and install the project (connect the device to the USB if you want):
$ react-native run-android
Fix ReferenceError: Can't find variable: __fbBatchedBridge:
Find you local ip address by executing ifconfig on Linux/Mac, for example:
inet addr:192.168.0.3
Shake the device to see menu options while app is running (if you don't have "Menu" button)
Go to Dev Settings -> Debug server host & port for device in Debugging section and copy your local ip address with the specific port:
192.168.0.3:8081 (the port can be viewed when running npm start from the first tab)
then go/press Back
Shake the device to see menu options again and press Enable Live Reload (to see changes live when editing)
Shake the device to see menu options again and press Reload JS
This worked for me according to documentation
http://facebook.github.io/react-native/docs/running-on-device-android.html#content
Using adb reverse
Note that this option is available on devices running android 5.0+ (API 21).
Have your device connected via USB with debugging enabled (see paragraph above on how to enable USB debugging on your device).
Run adb reverse tcp:8081 tcp:8081
You can use Reload JS and other development options with no extra configuration
Then Run react-native run-android which will automatically start dev server on 8081 port on your dev machine if not already running.
I encountered this when I had specified different react native versions in my packages.json and my build.gradle file. Making sure they matched, running npm update, and rebuilding from android studio fixed the issue for me.
I had the same problem.
As I followed all the steps mentioned in other answers, I could not resolve the issue.
In my case the firewall was blocking the packets coming from android.
Also If you have submitted your app for the iTunes store, also make sure that your jsCodeLocation is back to the localhost, as shown bellow:
jsCodeLocation = [NSURL URLWithString:#"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
/**
* OPTION 2
* Load from pre-bundled file on disk. The static bundle is automatically
* generated by "Bundle React Native code and images" build step.
*/
//jsCodeLocation = [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];

Resources