Remote Debugging Proxy Connection Problem

Problem:
Remote debugger is all set up as is the dbgproxy but dbgproxy keeps trying to contact Komodo directly from the remote server on port 9000 of my local machine… which it can’t do… which is why I am working to set up this proxy in the first place. Details are as follows but the conclusion of my efforts and final questions (for the executive summary) are at the very bottom of this post.


Here is what I have (all actual addresses obscured via example.com, 123.123.123.123, test_key):

  1. Remote server example.com on Linux platform
  2. Local Komodo on localhost on Mac OS
  3. A bunch of functional PHP on my remote server but would like Komodo Debugger to work for the next steps
  4. A remote internet connection run through an ATT Hotspot (I travel around full time in a trailer)

php.ini contains the following:
zend_extension="/path/to/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=example.com
xdebug.remote_port=9000
xdebug.idekey=test_key

Don’t forget to restart apache so php.ini changes go active.


I have confirmed appropriate setup of xdebug via phpinfo() on the remote server:

xdebug support enabled
Version 2.4.0-komodo
IDE Key test_key
Supported protocols Revision
DBGp - Common DeBuGger Protocol $Revision: 1.145 $
Directive Local Value Master Value
xdebug.auto_trace Off Off
xdebug.cli_color 0 0
xdebug.collect_assignments Off Off
xdebug.collect_includes On On
xdebug.collect_params 0 0
xdebug.collect_return Off Off
xdebug.collect_vars Off Off
xdebug.coverage_enable On On
xdebug.default_enable On On
xdebug.dump.COOKIE no value no value
xdebug.dump.ENV no value no value
xdebug.dump.FILES no value no value
xdebug.dump.GET no value no value
xdebug.dump.POST no value no value
xdebug.dump.REQUEST no value no value
xdebug.dump.SERVER no value no value
xdebug.dump.SESSION no value no value
xdebug.dump_globals On On
xdebug.dump_once On On
xdebug.dump_undefined Off Off
xdebug.extended_info On On
xdebug.file_link_format no value no value
xdebug.force_display_errors Off Off
xdebug.force_error_reporting 0 0
xdebug.halt_level 0 0
xdebug.idekey test_key test_key
xdebug.max_nesting_level 256 256
xdebug.max_stack_frames -1 -1
xdebug.overload_var_dump On On
xdebug.profiler_aggregate Off Off
xdebug.profiler_append Off Off
xdebug.profiler_enable Off Off
xdebug.profiler_enable_trigger Off Off
xdebug.profiler_enable_trigger_value no value no value
xdebug.profiler_output_dir /tmp /tmp
xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p
xdebug.remote_addr_header no value no value
xdebug.remote_autostart Off Off
xdebug.remote_connect_back Off Off
xdebug.remote_cookie_expire_time 3600 3600
xdebug.remote_enable On On
xdebug.remote_handler dbgp dbgp
xdebug.remote_host example.com example.com
xdebug.remote_log no value no value
xdebug.remote_mode req req
xdebug.remote_port 9000 9000
xdebug.scream Off Off
xdebug.show_error_trace Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars Off Off
xdebug.show_mem_delta Off Off
xdebug.trace_enable_trigger Off Off
xdebug.trace_enable_trigger_value no value no value
xdebug.trace_format 0 0
xdebug.trace_options 0 0
xdebug.trace_output_dir /tmp /tmp
xdebug.trace_output_name trace.%c trace.%c
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth 3 3


I have confirmed appropriate setup in Komodo at Komodo>Debugger>Connection:
Komodo should listen for debugging connections on:
x a specific port: 9000
I am running a debugger proxy and Komodo should use it:
is checked and set to:
Proxy Listener Address: example.com:9001
Proxy Key: test_key


I can start the proxy on the remote, linux server via:
./pydbgpproxy -i example.com:9001 -d example.com:9000


Which yields the following output:
INFO: dbgp.proxy: starting proxy listeners. appid: 940
INFO: dbgp.proxy: dbgp listener on example.com:9000
INFO: dbgp.proxy: IDE listener on example.com:9001


The remote server IP is:
123.123.123.123


The IP Address that Xdebug is seeing Komodo request from is (apparently as evidenced in the Server:onConnect):
456.456.456.456


And when I start the Komodo debugger listening via Debug>Listen For Debugging Connections, I get:
INFO: dbgp.proxy: Server:onConnect (‘456.456.456.456’, 64471) [proxyinit -p 9000 -k test_key -m 1]


And Debugger>Listener Status Tells me:
Debugger Listening: Yes
Host Address:
Host Port: 9000
Proxy Enabled: Yes
Proxy Key: test_key
Proxy Client Address: example.com
Proxy Client Port: 9000
Current Session: 0
Current Connections: 0
Total Connections: 0


Then when I start the debugger via:
http://example.com/test?XDEBUG_SESSION_START=test_key


I get:
INFO: dbgp.proxy: connection from 123.123.123.123:57335 [<main.sessionProxy instance at 0x1365c20>]


And… Komodo does absolutely nothing, the browser hangs and then times out with the proxy telling me:
ERROR: dbgp.proxy: Unable to connect to the server listener 456.456.456.456:9000 [<main.sessionProxy instance at 0x1365c20>]
Traceback (most recent call last):
File “./pydbgpproxy”, line 220, in startServer
self._server.connect((self._serverAddr[0], self._serverAddr[1]))
File “”, line 1, in connect
error: [Errno 110] Connection timed out
WARNING: dbgp.proxy: Unable to connect to server with key [test_key], stopping request [<main.sessionProxy instance at 0x1365c20>]
INFO: dbgp.proxy: session stopped


And if I try an invalid test key (bubba) I get:
INFO: dbgp.proxy: connection from 123.123.123.123:60471 [<main.sessionProxy instance at 0x111ab90>]
WARNING: dbgp.proxy: No server with key [bubba], stopping request [<main.sessionProxy instance at 0x111ab90>]
INFO: dbgp.proxy: session stopped


My conclusions so far (correct me if I’m wrong) are:

  1. Xdebug and the proxy are listening appropriately and accepting incoming request from Komodo and the Browser

  2. Instead of going back through the proxy to contact Komodo (Komodo should be listening to the proxy for incoming connections), Xdebug is attempting to contact Komodo on my local computer directly through my ATT Hotspot (which it can’t do and which is why I am working on setting up the proxy in the first place)

My questions are:

  1. Why should Komodo be listening for debugging connections on port 9000 of my local system (found at Komodo>Debugger>Connection)? Aren’t we running through a proxy for Komodo to listen on the remote port because the remote server can’t contact Komodo on my local machine?

  2. Have I done something wrong in the setup? I’ve followed the set-up directions to the letter and have tried many other solutions from other forums with no luck.

  3. Does anyone have input on a fix? It’s likely some stupid oversight on my part.

Thanks in advance… for now, I’ll go back to debugging the old fashioned way… bleh!

Fred

Nice write up @fctiv

The issue is where you’ve put the proxy and unfortunately I don’t think this is fixable in your case. Komodo is able to connect to the proxy but the proxy can’t talk back to Komodo. The server is publicly accessible. Komodo is not publicly accessible. That’s why Komodo doesn’t react and the process on the server hangs.

I found this line in the docs that explains as well as I could:

If you are debugging scripts on a remote web server that cannot connect to Komodo directly because of a firewall, you can run dbgpProxy on an intermediary server (e.g. a gateway) which can connect to Komodo and the web server on specified ports

In your case you would need a 3rd machine that is directly routable to and from both the remote server and the computer running Komodo which would server as the “gateway” server.

Sorry to be the bearer of bad new.

  • Carey

Oh wait…you know what might actually work here? You could setup an SSH tunnel. This would remove the need for the proxy. You point the debugger at one end and point Komodo at the other…I’ve only used an SSH tunnel a handful of times but they are pretty straight forward from what I remember.

I just found this how-to:

I think in your case your command would be something like this:
ssh -f fctiv@example.com -L 9000:example.com:9001 -N

  • Disable the proxy in Komodo
  • Tell it to listen on port 9000
  • Configure your Xdebug to send debug requests to 127.0.0.1:9001

Now everything should be funnelled through the tunnel…in theory…I really hope this works for you!

  • Carey

Thank you so much for the reply, @careyh! The SSH tunnel is a brilliant idea and I will give it a go… that really should work. You have also saved me from continuing to chase my original solution!

Thanks again!

Fred

As a follow-up, we just need to go the opposite direction with the tunnel:

ssh -R 9001:localhost:9000 user_name@example.com -f -N

We execute this on the localhost and this tells the remote server to send any traffic on the remote server to port 9001 back to the localhost at port 9000 (which is what Komodo is listening to now).

For completeness of this solution for others:

We can see that ssh is active on the localhost via:
ps aux | grep ssh

And we can see that the remote port 9001 is active via:
netstat -na | grep 9001

So, the final configuration is this:


in the php.ini file on the remote host server (the correct php.ini is located with phpinfo() under “Configuration File (php.ini) Path”):
in the “Dynamic Extensions” section:
; xdebug config for Linux and Mac OS X
zend_extension="/path/to/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
xdebug.idekey=test_key


In Komodo, under Komodo>Preferences>Debugger>Connection:
“Komodo should listen for debugging connections on”
“a specific port” is checked and is 9000
“I am running a debugger proxy…” is unchecked


In Komodo, click Debug>Listen For Debugging Connections - this should now show up as checked in the Debug menu


In the browser that is connecting to the remote host page you want to debug:
http://example.com/example_page?XDEBUG_SESSION_START=1


Komodo does the rest and now appropriately prompts for URI mapping


BUT… There is one more step! Komodo has output from the editor and that needs to get back to the remote server. Do this on the local server running Komodo (in addition to the ssh tunnel above):
ssh -L 9001:example.com:9001 user_name@example.com -f -N

Thanks again, @careyh!

Fred

NOTE: See the separate problem Mapped URIs not working to solve the a Mapped URI problem if necessary.

1 Like

A post was split to a new topic: Mapped URIs not working