| Author |
Message |
| < Server Side Extension Development ~ [TUTORIAL] Debug Smartfox at runtime |

|
|
Posted:
Tue Oct 02, 2007 1:48 pm
|
|
|
Joined: 02 Feb 2007
Posts: 154
Location: Stockholm Sweden
|
|
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
| Quote: |
# 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
| Quote: |
# 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: |
|
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 Thu Oct 04, 2007 9:26 pm; edited 1 time in total _________________ Nisse Bergman
Raketspel |
|
|
|
|
 |
|
Posted:
Wed Oct 03, 2007 6:03 am
|
|
|
Site Admin
Joined: 21 Mar 2005
Posts: 9086
Location: Italy
|
|
| Thanks Potmo, very well done. I've made the post a sticky. |
_________________ Lapo
--
gotoAndPlay()
...addicted to flash games |
|
|
|
|
 |
|
Posted:
Wed Oct 03, 2007 7:39 am
|
|
|
Joined: 17 Jun 2007
Posts: 17
|
|
| Excellent tutorial, went without a problem on Vista. Thanks for posting this Potmo! |
|
|
|
|
|
 |
|
Posted:
Tue Oct 16, 2007 9:20 am
|
|
|
Joined: 02 Feb 2007
Posts: 154
Location: Stockholm Sweden
|
|
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 |
|
|
|
|
 |
|
Posted:
Tue Oct 16, 2007 10:09 am
|
|
|
Joined: 02 Feb 2007
Posts: 154
Location: Stockholm Sweden
|
|
| 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 |
|
|
|
|
 |
|
Posted:
Tue Oct 16, 2007 12:39 pm
|
|
|
Site Admin
Joined: 21 Mar 2005
Posts: 9086
Location: Italy
|
|
| maybe you've got a personal firewall running? |
_________________ Lapo
--
gotoAndPlay()
...addicted to flash games |
|
|
|
|
 |
|
Posted:
Tue Oct 16, 2007 2:44 pm
|
|
|
Joined: 02 Feb 2007
Posts: 154
Location: Stockholm Sweden
|
|
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 |
|
|
|
|
 |
|
Posted:
Mon Mar 03, 2008 11:17 am
|
|
|
Joined: 17 Jun 2007
Posts: 17
|
|
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. |
|
|
|
|
|
 |
|
Posted:
Thu Mar 13, 2008 9:29 am
|
|
|
Joined: 13 Mar 2008
Posts: 1
Location: Hamburg, Germany
|
|
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. |
|
|
|
|
|
 |
|
Posted:
Sun Apr 06, 2008 10:27 pm
|
|
|
Joined: 04 Mar 2008
Posts: 13
Location: Las Vegas
|
|
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? |
|
|
|
|
|
 |
|
Posted:
Mon Apr 07, 2008 6:18 am
|
|
|
Joined: 02 Feb 2007
Posts: 154
Location: Stockholm Sweden
|
|
| 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 |
|
|
|
|
 |
|
Posted:
Mon Apr 07, 2008 8:14 pm
|
|
|
Joined: 04 Mar 2008
Posts: 13
Location: Las Vegas
|
|
| 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. |
|
|
|
|
|
 |
|
Posted:
Tue Apr 08, 2008 6:16 am
|
|
|
Joined: 02 Feb 2007
Posts: 154
Location: Stockholm Sweden
|
|
| 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 |
|
|
|
|
 |
|
Posted:
Tue Apr 08, 2008 6:48 am
|
|
|
Site Admin
Joined: 21 Mar 2005
Posts: 9086
Location: Italy
|
|
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 |
|
|
|
|
 |
|
Posted:
Wed Apr 09, 2008 7:50 pm
|
|
|
Joined: 04 Mar 2008
Posts: 13
Location: Las Vegas
|
|
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.  |
|
|
|
|
|
 |
|