-
Notifications
You must be signed in to change notification settings - Fork 2
SolarNode Debugging
Sometimes its useful to debug the SolarNode service running on an actual device, instead of locally in Eclipse. This guide explains how you can enable remote debugging support on the SolarNode service and then use Eclipse to remotely debug it.
First remote debugging must be enabled for the SolarNode service itself. ssh to the node and then
create an /etc/solarnode/env.conf file by copying the provided example:
cd /etc/solarnode
cp env.conf.example env.confThe example already contains the necessary additions to support remote debugging, namely the
JAVA_OPTS environment variable has this added to it:
-Xdebug -Xnoagent -Xrunjdwp:server=y,transport=dt_socket,address=9142,suspend=n
Now restart SolarNode:
sn-restartThat'll get the SolarNode service running with debugging enabled, with the debugger listening on port 9142.
This change will be persisted across device reboots. If you want to turn off remote debugging at
some point, just delete the /etc/solarnode/env.conf file or remove the -Xdebug -Xnoagent -Xrunjdwp...
settings, and then run sn-restart to apply the change.
Now to remotely debug the application first we need to create a TCP tunnel to the debug port 9142 on
the node. For that, use the port forwarding support of ssh like this:
ssh -L9142:localhost:9142 solar@solarnodeChange solarnode to whatever IP address the node is available on, if necessary. That'll make the
local port 9142 connect to the debugger running on the node. Leave the ssh connection alone, then
return to Eclipse.
Go to Run > Debug Configurations... in Eclipse. Right-click on Remote Java Application and select New from the menu. Fill in the details including:
- Project: net.solarnetwork.node
- Connection Type: Standard (Socket Attach)
- Host: localhost
- Port: 9142

If you also click on the Source tab here, you can add more projects to the configuration's source lookup path. Add any projects that contain Java classes that you're trying to debug.

Finally, click the Debug button and Eclipse should connect to the SolarNode service and debugging will proceed normally, just like you were running the SolarNode application locally inside Eclipse.