Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydbgpproxy - IDE Key already exists #3788

Closed
brsysadmin opened this issue Sep 24, 2019 · 3 comments
Closed

pydbgpproxy - IDE Key already exists #3788

brsysadmin opened this issue Sep 24, 2019 · 3 comments

Comments

@brsysadmin
Copy link

Short Summary

We have a problem with xdebug + PHPStorm + pydbgpproxy with the message : "IDE Key already exists".

We work in multi-user context and remotely :

  • we have the IDE on our laptop (client side)
  • we have Apache / PHP on a remote server (server side)

Steps to Reproduce

  • start the service pydbgpproxy
  • start a new xdebug session with a key (for example : myownkey) -> we can see the message for the key registration
  • debug
  • stop the xdebug session: we can see the message for the key unregistration
  • start a new xdebug session: we have an error with the message "IDE Key already exists"

If restart the pydbgpproxy service it's ok for ONE xdebug session with "myownkey".
Otherwise we have to change the key every time we want to start a debug session.

Expected results

We expect to start and stop as many xdebug sessions as we want without changing the key.

Actual results

We can't debug with ONE key per user.

Platform Information

Client side :

  • operating system : Linux Fedora 30 and Windows 10
  • IDE : PHPStorm 2019.2
  • PHP : 7.3.9

Server side :

Additional Information

@th3coop
Copy link
Member

th3coop commented Sep 24, 2019

@brsysadmin could you share the terminal output of this session including the command that starts the proxy? How are you starting the debug session? And finally, what's your php.ini config look like for debugging?

@brsysadmin
Copy link
Author

brsysadmin commented Sep 25, 2019

ABOUT THE PROXY

We manage the daemon with a SystemD service:

[Unit]
Description=pydbgpproxy
After=network.target
After=redis.service

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/pydbgpproxy/
Environment=PYTHONPATH=/opt/pydbgpproxy/pythonlib
ExecStart=/usr/bin/python2.7 pydbgpproxy -i <private ip address of the server>:9001 -d 127.0.0.1:9002
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

What I can see with 'journalctl -f -u pydbgpproxy' :
START OF THE PROCESS :

Sep 25 09:44:50 VM70 systemd[1]: Started pydbgpproxy.
Sep 25 09:44:50 VM70 python2.7[21646]: INFO: dbgp.proxy: starting proxy listeners.  appid: 21646
Sep 25 09:44:50 VM70 python2.7[21646]: INFO: dbgp.proxy:     dbgp listener on 127.0.0.1:9002
Sep 25 09:44:50 VM70 python2.7[21646]: INFO: dbgp.proxy:     IDE listener on  <private ip address of the server>:9001

DEVELOPER REGISTRATION :

Sep 25 09:45:48 VM70 python2.7[21646]: INFO: dbgp.proxy: Server:onConnect ('<private ip address of the developer's laptop>', 65235) [proxyinit -p 9002 -k testjc -m 1
Sep 25 09:45:48 VM70 python2.7[21646]: ]

DEVELOPER UNREGISTERATION :

Sep 25 09:46:16 VM70 python2.7[21646]: INFO: dbgp.proxy: Server:onConnect ('<private ip address of the developer's laptop>', 65246) [proxystop -k testjc
Sep 25 09:46:16 VM70 python2.7[21646]: ]

DEVELOPER REGISTRATION :

Sep 25 09:46:49 VM70 python2.7[21646]: INFO: dbgp.proxy: Server:onConnect ('<private ip address of the developer's laptop>', 65255) [proxyinit -p 9002 -k testjc -m 1
Sep 25 09:46:49 VM70 python2.7[21646]: ]

PHPSTORM SIDE

Our configuration in PHPStorm IDE:
Configuration of proxy via File > Settings > Languages & Frameworks > PHP > Debug > DBGp Proxy
IDE Key: testjc
Host:
Port 9001

Configuration of xDebug via File > Settings > Languages & Frameworks > PHP > Debug
Debug Port: 9002
Registration to the proxy via Tools > DBGp Proxy > Register IDE

What we can see in PHPStorm:

  • when we register our session just after starting the proxy:
    -> Start listening for debug via Run > Start Listening for PHP Debug Connections
09:45    Xdebug proxy: IDE successfully registered with ide key 'testjc'
  • when we stop our session:
    -> Cancel IDE Registration via Tools > DBGp Proxy > Cancel IDE Registration
09:46    Xdebug proxy: IDE successfully unregistered
  • when we try to restart our session without restarting the proxy:
    -> Registration again to the proxy via Tools > DBGp Proxy > Register IDE
09:46    Xdebug proxy: IDE Key already exists

@th3coop
Copy link
Member

th3coop commented Sep 25, 2019

@brsysadmin, My guess is that PHPStorm isn't killing the connection correctly when you disable the session from within the IDE. I confirmed that the proxy works as expected when used with Komodo.

SETUP:

  • xampp server with PHP xdebug configured to connect to the Proxy
  • proxy running in terminal
  • komodo configured to connect to proxy

Proxy output BEFORE debug session started:

>python pydbgpproxy.py -l DEBUG
INFO: dbgp.proxy: starting proxy listeners.  appid: 16468
INFO: dbgp.proxy:     dbgp listener on 127.0.0.1:9000
INFO: dbgp.proxy:     IDE listener on  127.0.0.1:9001
INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 54439) [proxystop -k cgcho]
INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 54441) [proxyinit -p 10000 -k cgch -m 1]

Proxy output during debug session:

INFO: dbgp.proxy: connection from 127.0.0.1:54443 [<__main__.sessionProxy instance at 0x000000000381B788>]
DEBUG: dbgp.proxy: session getting data
DEBUG: dbgp.proxy:    data: ['517\x00<?xml version="1.0" encoding="iso-8859-1"?>\n<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///[path to xampp]/xampp/htdocs/phpinfo.php" language="PHP" xdebug:language_version="7.0.7" protocol_version="1.0" appid="17624" idekey="cgch"><engine version="2.4.0-komodo"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>\x00']
DEBUG: dbgp.proxy: session dispatching call '<?xml version="1.0" encoding="iso-8859-1"?>\n<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///[path to xampp]/xampp/htdocs/phpinfo.php" language="PHP" xdebug:language_version="7.0.7" protocol_version="1.0" appid="17624" idekey="cgch"><engine version="2.4.0-komodo"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>'
DEBUG: dbgp.proxy: Sending init to ide 548 '<?xml version="1.0" encoding="UTF-8"?>\n<init appid="17624" fileuri="file:///[path to xampp]/xampp/htdocs/phpinfo.php" hostname="127.0.0.1" idekey="cgch" language="PHP" protocol_version="1.0" proxied="true" xdebug:language_version="7.0.7" xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug"><engine version="2.4.0-komodo"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>'
DEBUG: dbgp.proxy: destructor [<__main__.sessionProxy instance at 0x000000000381B788>]

[NEW SESSION STARTED HERE WITH NO RESTART]

INFO: dbgp.proxy: connection from 127.0.0.1:54448 [<__main__.sessionProxy instance at 0x000000000384F748>]
DEBUG: dbgp.proxy: session getting data
DEBUG: dbgp.proxy:    data: ['517\x00<?xml version="1.0" encoding="iso-8859-1"?>\n<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///[path to xampp]/xampp/htdocs/phpinfo.php" language="PHP" xdebug:language_version="7.0.7" protocol_version="1.0" appid="17624" idekey="cgch"><engine version="2.4.0-komodo"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>\x00']
DEBUG: dbgp.proxy: session dispatching call '<?xml version="1.0" encoding="iso-8859-1"?>\n<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///[path to xampp]/xampp/htdocs/phpinfo.php" language="PHP" xdebug:language_version="7.0.7" protocol_version="1.0" appid="17624" idekey="cgch"><engine version="2.4.0-komodo"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>'
DEBUG: dbgp.proxy: Sending init to ide 548 '<?xml version="1.0" encoding="UTF-8"?>\n<init appid="17624" fileuri="file:///[path to xampp]/xampp/htdocs/phpinfo.php" hostname="127.0.0.1" idekey="cgch" language="PHP" protocol_version="1.0" proxied="true" xdebug:language_version="7.0.7" xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug"><engine version="2.4.0-komodo"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>'
DEBUG: dbgp.proxy: destructor [<__main__.sessionProxy instance at 0x000000000384F748>]

[DISABLE THEN REENABLE CONNETION TO PROXY FROM WITHIN KOMOWO, NO RESTART]

INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 54516) [proxystop -k cgch]
INFO: dbgp.proxy: Server:onConnect ('127.0.0.1', 54523) [proxyinit -p 10000 -k cgch -m 1]

You should open a ticket with PHPStorm to see what might be going on on their end.

@th3coop th3coop closed this as completed Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants