Expand my Community achievements bar.

SOLVED

Could not establish Connection

Avatar

Level 1

When attempting to debug I get the following error:

could not establish debug connection to localhost : 10123
Failed to connect to remote VM. Connection refused.
Connection refused: connect

 

I use the following command to start the instance:  java -Xms2048m -Xmx2024m -agentlib:jdwp=transport=dt_socket,address=10123,server=y,suspend=n -jar aem-author-p4502.jar

My debug port is 10123 and I have "resolve sources when connecting"  unchecked.  

The server is up an running.   Other folks have pointed to articles on this page, but they appear to not be here.

 

Please help

 

Thanks,

Glenn

 

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I am using below steps to debug -

 

Go to bin folder in crx-quickstart and change the line 25 in start.bat by adding the highlighted part here (address port number can be any number of your choice)

if not defined CQ_JVM_OPTS set CQ_JVM_OPTS=-Xmx1024m -XX:MaxPermSize=256M -Djava.awt.headless=true -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10123

Change line no. 44 by adding this

set CQ_RUNMODE=%CQ_RUNMODE%,crx3,crx3tar,debug

Save the file.

Once saved open the command prompt, go to \crx-quickstart\bin and type “start.bat”, once it’s done you’ll see another window of cmd being opened and the server will start in debug mode as seen below

DEBAL_DAS_0-1647749205862.png

 

Check if the server is started or not by opening localhost:4502 in the browser

Setting up the debug config in eclipse

Go to Run -> Debug Configurations -> Remote Java Application

Set up a new configuration like seen below by selecting the project (mostly it’ll be core) and click Debug

 

DEBAL_DAS_1-1647749266572.pngDEBAL_DAS_2-1647749289029.png

Eclipse by default will suspend execution on uncaught exceptions which will debug the code which we haven’t even selected. This will waste our time. So please do this to avoid it

Go to Windows - > Preferences -> Java -> Debug and uncheck “Suspend execution on uncaught exceptions”

DEBAL_DAS_3-1647749345154.png

Set debug points in your code and explore! Try this and let me know whether it helps or not.

View solution in original post

5 Replies

Avatar

Correct answer by
Employee Advisor

I am using below steps to debug -

 

Go to bin folder in crx-quickstart and change the line 25 in start.bat by adding the highlighted part here (address port number can be any number of your choice)

if not defined CQ_JVM_OPTS set CQ_JVM_OPTS=-Xmx1024m -XX:MaxPermSize=256M -Djava.awt.headless=true -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10123

Change line no. 44 by adding this

set CQ_RUNMODE=%CQ_RUNMODE%,crx3,crx3tar,debug

Save the file.

Once saved open the command prompt, go to \crx-quickstart\bin and type “start.bat”, once it’s done you’ll see another window of cmd being opened and the server will start in debug mode as seen below

DEBAL_DAS_0-1647749205862.png

 

Check if the server is started or not by opening localhost:4502 in the browser

Setting up the debug config in eclipse

Go to Run -> Debug Configurations -> Remote Java Application

Set up a new configuration like seen below by selecting the project (mostly it’ll be core) and click Debug

 

DEBAL_DAS_1-1647749266572.pngDEBAL_DAS_2-1647749289029.png

Eclipse by default will suspend execution on uncaught exceptions which will debug the code which we haven’t even selected. This will waste our time. So please do this to avoid it

Go to Windows - > Preferences -> Java -> Debug and uncheck “Suspend execution on uncaught exceptions”

DEBAL_DAS_3-1647749345154.png

Set debug points in your code and explore! Try this and let me know whether it helps or not.

Avatar

Employee Advisor

@geverett , the above mentioned solution by @DEBAL_DAS is appropriate and should work, however make sure :

  •  The port you are using is free to use (avoid :80 / :8080) for debug since they are generally occupied ports.

Thanks.

Avatar

Level 1

I followed the above recommendations, and still I'm getting an error trying to connect.

My start.bat has the lines:

if not defined CQ_JVM_OPTS set CQ_JVM_OPTS=-Xmx4096m -XX:MaxPermSize=256M -Djava.awt.headless=true -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10123

and

set CQ_RUNMODE=%CQ_RUNMODE%,crx3,crx3tar,debug

 

After starting the server, when I click on the debug option I get the following error.

 

geverett_1-1647974678878.png

 

 

 

 

Avatar

Employee Advisor

Are you trying to define a new server like below one -

DEBAL_DAS_0-1648006712470.png

I didn't add server explicitly. After making necessary change in start.bat file I just opened the command prompt, go to \crx-quickstart\bin and type “start.bat” and press enter.

Avatar

Employee Advisor

Here you could see I am able to debug -

 

DEBAL_DAS_0-1648015299586.png