[TUTORIAL] Debug Smartfox at runtime

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

[TUTORIAL] Debug Smartfox at runtime

Post by potmo »

Heres a tutorial on how to debug smartfox at runtime.
Its actually really easy!

This one has been tested on Win Xp in Eclipse. I Have no idea if it works on any other system. This is also for debugging on you local machine. That is to say You run the server on the same PC as you run Eclipse on.

The basic idea is that you run smartfox as a service but with a consolewindow (to get the System.out.println();)


-------------------------------------------------------------------

C:\Program\SmartFoxServerPRO\ is my rootfolder for smartfox


in C:\Program\SmartFoxServerPRO\Server\conf\wrapper.conf
you got some lines saying
# Java Additional Parameters
wrapper.java.additional.1=-Dfile.encoding=UTF-8
wrapper.java.additional.2=-Djava.util.logging.config.file=logging.properties
Directly after that add theese lines
# runtimedebug
wrapper.java.additional.3=-Xdebug
wrapper.java.additional.4=-Xnoagent
wrapper.java.additional.5=-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
Now make a .bat-file (jsu rightclick in a folder -> click new -> textdocument -> name the textdocument to e.g. "smarfoxService.bat")

copy this line and change the paths so it points at your wrapper.exe

Code: Select all

C:\Program\SmartFoxServerPRO\Server\wrapper.exe -c "C:\Program\SmartFoxServerPRO\Server\conf\wrapper.conf"
Run the .bat by just dubbelclicking it!

Now its time to set up Eclipse!
Click the green "bug"-icon (up to the left in eclipse)
select "Remote Java Application"
click new

Insert this:
ConnectionType: Standard (Socket Attach)

Connection Properties:
Host: localhost
Port: 8787

Click "Debug"


Done!

Hope this will make someones day easier! Post a reply if you dont get it to wor and i'll try to help
Last edited by potmo on 04 Oct 2007, 21:26, edited 1 time in total.
Nisse Bergman
Raketspel
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Thanks Potmo, very well done. I've made the post a sticky.
Lapo
--
gotoAndPlay()
...addicted to flash games
Luc
Posts: 18
Joined: 17 Jun 2007, 21:05

Post by Luc »

Excellent tutorial, went without a problem on Vista. Thanks for posting this Potmo!
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post by potmo »

its seems as it stopped working.
Can it be the new v1.5.9?

I get a "Failed to connect to remove VM. Connection refused."

Anyone got an idea?

There was some time ago i remote debugged last time so i dont know if i have done anything else stupid.
Nisse Bergman
Raketspel
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post by potmo »

potmo wrote:its seems as it stopped working.
Can it be the new v1.5.9?

I get a "Failed to connect to remove VM. Connection refused."

Anyone got an idea?

There was some time ago i remote debugged last time so i dont know if i have done anything else stupid.
My fellow coworker got it working so i guess ive done something stupid
Nisse Bergman
Raketspel
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

maybe you've got a personal firewall running?
Lapo
--
gotoAndPlay()
...addicted to flash games
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post by potmo »

I got it working by saving all and restarting both the server and Eclipse.
Could have been that the servver where out of sync with the source or something.
Nisse Bergman
Raketspel
Luc
Posts: 18
Joined: 17 Jun 2007, 21:05

Post by Luc »

I also got the 'Failed to connect to remote VM. Connection refused.' message today.
I tried a lot of things to get it to work (check Vista's firewall, run as administrator, change some Eclipse settings) to no avail. I did finally find one way of getting a connection - in wrapper.conf, I changed 'suspend' to 'y'. This causes the wrapper to halt until a connection is made with the debugger. I was then able to connect with Eclipse.
Biele
Posts: 1
Joined: 13 Mar 2008, 09:10
Location: Hamburg, Germany

probably trying to connect twice?

Post by Biele »

Sorry if this hint seems a bit ridiculous, but I got the 'Failed to connect to remote VM. Connection refused.' message when I accidentally tried to connect from Eclipse to the SmartFoxServer twice.
This happens easily when Eclipse is not configured to automatically turn to Debug perspective on start of debugging.
Zak
Posts: 13
Joined: 04 Mar 2008, 07:41
Location: Las Vegas
Contact:

Post by Zak »

I connected to it fine using the "suspend=y" method posted above.

The console thing came up in eclipse, but it was blank and stayed blank through the execution of my program. The cmd window had output in it as usual, but nothing was in eclipse. What should I be seeing? Does this only work for java extensions, and not for anything in python? Do I have to import something in python to use System.out.println or whatever?

Is there a way to set breakpoints and step into and out of code?
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post by potmo »

i cannot help you any more than the tutorial. Make sure that you have followed all steps in the tutorial an you'll be able to remote debug and set breakpoints...
Nisse Bergman
Raketspel
Zak
Posts: 13
Joined: 04 Mar 2008, 07:41
Location: Las Vegas
Contact:

Post by Zak »

potmo wrote:i cannot help you any more than the tutorial. Make sure that you have followed all steps in the tutorial an you'll be able to remote debug and set breakpoints...

Does this work with python extensions as well as java or actionscript ones? Maybe that could be where I am going wrong...

What extension types are you using exactly?

I have followed all the steps carefully and meticulously. I now believe that differences in my situation may be the culprit, instead of not following steps. Is anybody else able to debug python extensions? I am using eclipse, but with the pydev plugin. That could be the problem as well.

Just trying to narrow it down. This information I'm putting here might help others figure out why it doesn't work for them as well. :)


Anyways, thank you for your help. I will play with it some more. Setting breakpoints would be VERY nice, as I have been stuck relying on _server.trace statements to debug, which is very tedious.
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post by potmo »

I havent tried Python but as I have understood it; all pythoncode is converted into Java. I dont know what this will do to realtime debug with breakpoints. I hope anyone here at the forum can help you. Otherwise there might be some other forums specificly targeting python that might be able to help you.
Nisse Bergman
Raketspel
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

potmo is right, python code is compiled into java bytecode.
If you attach the debugger you could be able to see the Java representation of the Python code, I fear it could get a little confusing although classes like PyTuple, PyObject etc... should be self explanatory.
Lapo
--
gotoAndPlay()
...addicted to flash games
Zak
Posts: 13
Joined: 04 Mar 2008, 07:41
Location: Las Vegas
Contact:

Post by Zak »

I have gotten so close...

I still can't seem to have my breakpoints hit from the debugger.

Here's a screen shot of what I'm seeing in eclipse: http://outrunpoker.com/screenshot.jpg


Basically, I know for certain that I am connected to the remote debugger session because I can pause and start it with the buttons in eclipse. However, I placed a breakpoint here in my code, a simple trace statement on the init function. I reload the extension, so that break point should be hit, but it never does, no matter where I place it.

I have followed the instructions fanatically and methodically. Any additional insight would be appreciated. I feel I'm too close to give up. :)
Post Reply