Remote debugging Meteor / Nodejs with Atom - node.js

Can anyone help me using Atom for remote debugging a Meteor / Node app on another machine?
Have my meteor app with node inspector --inspect-brk running on a linux machine:
Debugger listening on ws://0.0.0.0:24010/3a1f6bec-6f4d-439a-b086-af78cc27c9ea
And on my windows machine i have the Atom editor and the source code.
I tried out different atom-debug packages, but to me they seem only to work when both Atom and Node / Meteor are on the same machine and also Atom can launch the meteor or node app itself.
In my case i want to attach to the remote debugger to a running instance on the other machine.
Does anyone know how it is done?

I think you need to specify an IP address to the inspect-brk parameter to get it to work remotely. You message is binding to 0.0.0.0 which cannot be seen remotely.
I think the format is —-inspect-brk=your.ip.address.here:portnumber entering a valid IP address fo the server and the port number you wish to debug on. This is from memory as I cannot see my startup code as I type this.

Related

Installing Node Application on a server. Apache npm pm2

I have installed a node js application (myapp.js) on a server with a particular IP.
I have npm installed and started the application
I have done this before but it was with apache and much more complex.
However this is the only application on this server. It is running fine.
Shouldn't this just be available at the ip it is installed on?
My own guess is it is something to do with the node setup within the application, as its referring to a local host 8050? Maybe this needs to be an IP?
Edit
I have just installed the application on the server. I havent set up any apache so maybe that is the issue. I think perhaps because i defined a port within the application it then needs a port specified on the server?
Your node application could be accessed locally from:
http://localhost:8050/
And from outside at:
http://youripaddress:8050/
Assuming that port 8050 is open, naturally.
You can also setup a reverse proxy with apache or nginx (or anything else) to proxy your application.

Connection refused while using debugger

I have attached a node debugger to my JS file and after attaching the debugger to the js file which is a server running on port 8080 while I try to access it using localhost - it gives the following error message:
The node version is v6.11.2 and the debugger which gets attached is the one comes with the node(default) like
node debug JSONServer.js
The module used in the file are core modules http and https and the OS of the machine is Windows 10
connection refused
Please suggest what can be the reason.
Thanks
All,
Later I tried running the debugger from Atom with the package node-debugger
Still it gave same error
Connection Refused
Then I tried to attach the debugger outside Atom with following command
node --debug=5858 JSONServer.js
And Opened the debugger in Atom and this time the Debugger worked in Atom.

how to run nodejs app in vps with plesk enable

Hi guys im newbie in vps... I've bought an ovh not managed vps . I like to face problems... But I don't find any documents to these one. Is simple like I said I want to run a nodejs app in centos vps environment but I have enabled plesk.. and I saw in console running the app with the trace but I try to open website with the port and doesn't find anything.
http://vps406315.ovh.net
Thx for all guys
-----------------EDIT-------------------
I'm going to explain better,sorry for previous post.
There is no error, in my console all is ok. Like I said i have an CentOS VPS. Steps that I did:
Connect with PUTTY
Go to folder where is the NodeJS project.
I set the port to 8080
Write node index.js
The app is running and writing the right trace.
I use chrome to check the ip, and show me the default plesk page.
I use wget to check it, and with only http://92.222.71.137/. I attach
an screenshot
I tried to use with the port 8080 with the chrome and wget in putty,
and the response was the same.
In the other hand if I use http://92.222.71.137:8080/login with putty
download the right login.html, and the nodejs app write a trace
indicate me that someone connect to that page. But if I access with
chrome is not working.
Now I would like no know how to make access frome Chrome.
Thx 4 all and sorry for my newbie knowledge
You should give some other details on the configuration or eventual errors you get (both on the browser and the VPS) and how you run the node app (behind a web server, for example)
If you are not running you node app behind a web server, are the node app listening on the correct interface ? 127.0.0.1 and 92.222.71.137 (your site external address) are not the same.
On your VPS you can try to call the node app from the VPS itself using wget or cURL and looking for what happen in the app trace.
Finally it was easy... only i had to open a port to use with TCP, using
iptables -I INPUT -p tcp --dport 8856 --syn -j ACCEPT –

Unable to access node server running on specific port from other machine

I am running node server running react application.server is run by webpack. Server is running on 10.121.45.23:3005. I tried opening the application on other machine but page displays connection timed out. I have tried following things to resolve the issue, but nothing helped.
ping 10.121.45.23 from another machine. It is successful.
On server, netstat -ano. I am able to see 10.121.45.23:3005 listening. No loopback address was there as mentioned in many answers on Stack Overflow.
On another machine,telnet 10.121.45.23 3005. It fails and say cannot connect on port 3005. Telnet to some other port on which java is running, is successful. It fails only for node.js server.
So my problems are:
telnet is not working to that port.
Not able to open application on other machine's browser.
Am I missing any checks?
Sounds like you've tested quiet a bit. Have you tried another port, just in case there's a firewall or something?
Also, try explicitly telling webpack to listen on the all-hosts address 0.0.0.0
webpack-dev-server --port 9000 --host 0.0.0.0

Remotely debugging my node app that is hosted on AWS

I would like to connect to my node server running in debug mode on AWS (node --debug app.js) from my development machine, and be able to debug my app remotely.
Two questions:
Can I do this with node-inspector? I wish I could, but node-inspector fails to install on my AWS instance.
Any alternatives that will allow me to do this?
And with the help of tepez's answer, the following worked for me (Node Inspector v0.12.2):
On my machine:
ssh -L 8080:127.0.0.1:8080 <username>#<host> -N
On the remote server:
node-debug --cli <appname>
And enter the following address in the browser:
127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858
Forward remote debugger port with ssh from your dev machine
ssh -L 5858:127.0.0.1:5858 ubuntu#some.ec2.host.com
And now you can start node-inspector as if the debugger is running locally.
Allow me to present an alternative using node --inspect. I had the same need, although in a Windows environment, I believe this should work for you.
Remote machine (tested with Node 6.10.2, Windows Server 2012)
node --inspect=0.0.0.0:9229 <appname>.js
Local Machine (tested with Win 10, Chrome 60.0.3112.90)
In Chrome DevTools - Click the vertical ellipsis menu in top right:
Go to: More Tools -> Remote Devices
Under Network targets Click Add address
Enter <remote-ip>:9229
Once you enter address and remote target is connected you'll see Node.JS Icon on Top Left of DevTools
Click NodeJS Logo to launch DevTools Node Debugger
Screenshots of Steps 1,3,4 below.
One more option to use 0.0.0.0 to listen to request from outside:
node-debug --web-host=0.0.0.0 --cli app.js
and visit this address to debug:
http://<the-domain>:8080/?port=5858
it would be better if HTTP/2 is available since there are lots of small files.
You can use node --inspect too in your remote machine.
Start your node with node --inspect myapp.js
Then locally ssh -L 9229:127.0.0.1:9229 myuser#myserver -N
Search for an string like this at the log head and copy it
chrome-devtools://devtools/remote/serve_file/#60cd6e859b9ff284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/bef2ae68
Paste it in your chrome browser
Enjoy :)
If you are using pm2 just add this on your ecosystem.js
"apps": [{
"name": "myapp",
"script": "index.js",
"node_args": ["--inspect"],
...
Also you can specify --web-host argument.
node-inspector --web-host host.amazonaws.com
This is what worked for me:
Start node-inspector on server.
Start debugee on remote server with --debug flag.
Note the port that the debugger listens on, i.e. Debugger listening on port DEBUG_PORT message.
Create an ssh tunnel for port 8080, not the DEBUG_PORT as Andrey Sidorov's answer suggests.
Open SERVER_API:8080/debug?ws=127.0.0.1:8080&port=DEBUG_PORT in browser an voilà.
Node Inspector v0.10.1

Resources