Reputation: 1
We are a team using a docker stack for different projects on a remote server (better performance than Mac). These stack have several services such as PHP (with Xdebug), DBGp, ElasticSearch....
I've been working on an issue for 2 weeks and can't solve it. I can't debug using this stack on a remote server (it's working very well on my local computer but it's very slow and losing too much time). I think the ssh tunnel is doing wrong
Here is a some information :
Xdebug config:
[xdebug]
xdebug.max_nesting_level=2048
xdebug.remote_enable=1
xdebug.remote_connect_back=0
xdebug.remote_port=9001
xdebug.remote_host=dbgp
xdebug.idekey=PHPSTORM
xdebug.remote_log="/var/www/html/public/xdebug.log"
Xdebug logs:
[6] Log opened at 2021-01-20 09:00:21
[6] I: Connecting to configured address/port: dbgp:9001.
[6] I: Connected to client. :-)
[6] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/public/test.php" language="PHP" xdebug:language_version="7.3.20" protocol_version="1.0" appid="6" idekey="PHPSTORM"><engine version="2.9.6"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
[6] <- proxyerror -i 1 -- VW5hYmxlIHRvIGNvbm5lY3QgdG8gdGhlIHNlcnZlciBsaXN0ZW5lciA5Mi4xODQuMTAwLjIyNTo5
MDAxIFs8X19tYWluX18uc2Vzc2lvblByb3h5IGluc3RhbmNlIGF0IDB4N2Y5Y2VjZDFkNWYwPl0=
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="proxyerror" transaction_id="1"><error code="4"><message><![CDATA[unimplemented command]]></message></error></response>
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[6] <- proxyerror -i 2 -- VW5hYmxlIHRvIGNvbm5lY3QgdG8gc2VydmVyIHdpdGgga2V5IFtQSFBTVE9STV0sIHN0b3BwaW5n
IHJlcXVlc3QgWzxfX21haW5fXy5zZXNzaW9uUHJveHkgaW5zdGFuY2UgYXQgMHg3ZjljZWNkMWQ1
ZjA+XQ==
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="proxyerror" transaction_id="2"><error code="4"><message><![CDATA[unimplemented command]]></message></error></response>
[6] Log closed at 2021-01-20 09:00:52
DBGp config from docker-compose.yml (launching a Dockerfile using komodo-python-dbgp):
dbgp:
build:
context: './.docker/dbgp/'
ports:
- ${DBGP_PORT}:9002
DBGp logs:
dbgp_1 | 2021-01-20T08:59:34.893975559Z INFO: dbgp.proxy: dbgp listener on 0.0.0.0:9001
dbgp_1 | 2021-01-20T08:59:34.893982748Z INFO: dbgp.proxy: IDE listener on 0.0.0.0:9002
dbgp_1 | 2021-01-20T09:00:01.496772798Z INFO: dbgp.proxy: Server:onConnect ('92.184.100.225', 43547) [proxyinit -p 9001 -k PHPSTORM -m 1]
dbgp_1 | 2021-01-20T09:00:21.203770947Z INFO: dbgp.proxy: connection from 192.168.192.9:57390 [<__main__.sessionProxy instance at 0x7f9cecd1d5f0>]
dbgp_1 | 2021-01-20T09:00:52.648803308Z ERROR: dbgp.proxy: Unable to connect to the server listener 92.184.100.225:9001 [<__main__.sessionProxy instance at 0x7f9cecd1d5f0>]
dbgp_1 | 2021-01-20T09:00:52.648853429Z Traceback (most recent call last):
dbgp_1 | 2021-01-20T09:00:52.648864741Z File "/usr/bin/pydbgpproxy", line 220, in startServer
dbgp_1 | 2021-01-20T09:00:52.648874088Z self._server.connect((self._serverAddr[0], self._serverAddr[1]))
dbgp_1 | 2021-01-20T09:00:52.648882211Z File "/usr/lib/python2.7/socket.py", line 228, in meth
dbgp_1 | 2021-01-20T09:00:52.648890343Z return getattr(self._sock,name)(*args)
dbgp_1 | 2021-01-20T09:00:52.648898305Z error: [Errno 110] Operation timed out
dbgp_1 | 2021-01-20T09:00:52.649270051Z WARNING: dbgp.proxy: Unable to connect to server with key [PHPSTORM], stopping request [<__main__.sessionProxy instance at 0x7f9cecd1d5f0>]
dbgp_1 | 2021-01-20T09:00:52.649739684Z INFO: dbgp.proxy: session stopped
SSH command I'm using to redirect to my local:
ssh -R 9001:127.0.0.1:25115 user@server
With :
I also tried to change 127.0.0.1 to the app's docker Gateway address but still didn't work.
I register my IDE in Tools > DBGp Proxy > Register IDE
from PhpStorm.
When I load a php page on my app, it just loads for 30 seconds and display logs I put at the top.
What am I doing wrong and can anyone help me please? 😕
Upvotes: 0
Views: 633
Reputation: 3043
It seems to be possible to make this work, but your configuration has to be re-done completely.
The SSH tunnel doesn't make any sense. On the server, you map 25115 to port 9002 of the dbgp container, and at the same time, you are trying to listen on the same port by SSH to redirect this port to your dev machine?
The proxy initiates new connections to registered IDEs by taking the IP the registration came from, with Docker port mappings (25115:9002), it would be 127.0.0.1, so the container will try to send the debug data to itself, which obviously is not going to work.
What you need to do - please check my comment here, specifically, this screencast.
You'll need to modify the proxy code so that it initiated the debug connections to the Docker host and used the IDE keys as port numbers.
In my screencast, I've used '127.0.0.1', in your case, this should be a hostname/IP that the container can use to connect to the Docker host. On Linux, I usually use the eth0 interface address.
If I got you right, port 25115 is publically available on the server, so you need no tunnel to connect to it.
What you need the tunnel for is that each dev should listen on their personal port on the server so that the proxy could send the data over the tunnel to the devs' machines.
The tunnel should look like ssh -R 8123:127.0.0.1:9001
where:
That's kinda it, please give it a try.
Upvotes: 1