Gobliins
Gobliins

Reputation: 4026

howto remote debug server code on meteor?

When i start my Server with:

 ROOT_URL="http://myserver:24000" meteor debug --settings config/settings.json --port 24000 --inspect

i get the cosole log:

Debugger listening on ws://127.0.0.1:9229/a540a686-0a99-4a2a-ae85-bf06f74bc274
For help see https://nodejs.org/en/docs/inspector

But when i try to access http://myserver:9229/a540a686-0a99-4a2a-ae85-bf06f74bc274 i get site is not available....

I am using:

Meteor v1.8.0.2
Node: v8.11.4


NOTE: I want to remote debug, i am not on the same machine where my meteor app is running.

Upvotes: 1

Views: 420

Answers (2)

Gobliins
Gobliins

Reputation: 4026

I found the Problem, i have not added a host to the --inspect parameter. Now its working by adding --inspect=0.0.0.0:9229

Upvotes: 0

Jankapunkt
Jankapunkt

Reputation: 8423

To remote debug your Meteor app you now can just use the node internal inspector and omit the debug command:

ROOT_URL="http://myserver:24000" meteor --inspect --settings config/settings.json --port 24000

which now runs your Meteor app as usual with public port 24000. Now the console should show you the following output:

=> Started proxy.                             
=> Started MongoDB.                           
W20190218-21:01:14.539(1)? (STDERR) Debugger listening on ws://127.0.0.1:9229/2ee5da2d-c15b-416a-9efc-a19bb1299f35
W20190218-21:01:14.552(1)? (STDERR) For help see https://nodejs.org/en/docs/inspector
=> Started your app.

=> App running at: http://myserver:24000/

In order to remote debug your server-side code you need a node inspector client to attach to ws://127.0.0.1:9229/2ee5da2d-c15b-416a-9efc-a19bb1299f35 which is a websocket-based location and cannot be used via http://....

If you use chrome you can just enter chrome://inspect and look in the list of Remote Target where there should be an entry with your Meteor app Target (v8.11.4) (which is the internal node version of Meteor 1.8.0.2). Click on inspect and the console should now print

W20190218-21:08:48.039(1)? (STDERR) Debugger listening on ws://127.0.0.1:9229/2ee5da2d-c15b-416a-9efc-a19bb1299f35 W20190218-21:08:48.040(1)? (STDERR) For help see https://nodejs.org/en/docs/inspector W20190218-21:08:49.291(1)? (STDERR) Debugger attached.

Now open your app in another tab or browser window via http://myserver:24000/ and use it until the debugger breakpoints on the server side code is triggered and watch the inspector tab switch to debugging mode (as you may already know from client debugging).

Upvotes: 2

Related Questions