NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Debugging requests from one host to another


Joined: 10 Sep 2013
Posts: 9
Reply with quote
On my local PC I have Nusphere PhpEd installed and also I have two similar VirtualBox VMs with installed DBG plugin. Both VMs contain Apache with PHP Web applications.

I configured remote debugging successfully so I can put debugbreak() in the code on VM1 and when I open it in browser it starts debugger in the PhpEd successfully. I can do the same when I run requests to the VM2.

Now the trick is that I have some requests to Webapp on VM1 and it then does HTTP requests to Webapp on VM2 on its own (using Guzzle).

Can I somehow configure the debugger so that I can put debugbreak() in the webapp on VM2 and it will start the debugger on my host machine? The problem is that VM2 doesn't know where my Nusphere is installed, it sees the client ip as the ip of VM1.

There is a "debugger.ports=7869" configuration but is there "debugger.host" or something like this?

Host and VMs can access each other and have Ips like.
192.168.56.1 - host
192.168.56.5 - VM1
192.168.56.6 - VM2

So they are all in the same virtual network.
View user's profileFind all posts by ruslanbesSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
your script on VM1 that sends HTTP requests to VM2 should also send DBGSESSID http GET, POST or COOKIE variable that it got from the IDE. So if you start debugging VM1, you'll transparently switch to debugging script on VM2.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 10 Sep 2013
Posts: 9
Reply with quote
Shouldn't I also create portforward of the default debugger port (7869) from VM1 to my host PC?

I tested the setup as you suggested - my VM1 script looks for the value
Code:
$_COOKIE['DBGSESSID']
and sends it to the VM2 also as a cookie with the same name. Its value is
Code:
1;d=1,p=0

I also changed the dbg.ini value on VM2 to
Code:
debugger.hosts_allow=ALL

that fixed the hosts restriction.

Currently my case is following - VM1 script starts debugging, gets to the point where it sends HTTP request to VM2 and hangs there. I suspect VM2 looks for the debugger client but can't find it. Or I'm missing something here.

Setup:
Host PC: Windows x64, Nusphere 17.0
VM1 and VM2 both: Linux 14x64
VM1's PHP: 5.6
VM2's PHP: 5.4

Separately they both work like charm.
View user's profileFind all posts by ruslanbesSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
1;d=1,p=0
-- it's not entirely correct. Should be 1@ipaddresshere:porthere;d=1,p=0
What you have may work on local machine, but I can't imagine how debugger on VM1 or VM2 would find the IDE.
Do you have sort of filters in HTTP? May be they recognize "@ipaddresshere:porthere" as http username/password and strip them?

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 10 Sep 2013
Posts: 9
Reply with quote
dmitri wrote:
Quote:
1;d=1,p=0
-- it's not entirely correct. Should be 1@ipaddresshere:porthere;d=1,p=0
What you have may work on local machine, but I can't imagine how debugger on VM1 or VM2 would find the IDE.
Do you have sort of filters in HTTP? May be they recognize "@ipaddresshere:porthere" as http username/password and strip them?


Passing "@ip:port" worked. Thanks! That was my mistake.

The thing is most of the time I work normally and just put debugbreaks around the code and press F5 in browser - so DBG session starts when it encounters one. In this case I either have no DBGSESSION or DBGSESSION=-1. I guess in my case debugger simply looked at the client ip address and assumed it by default.

I tried to build DBGSESSION manually and didn't included ip address - that was my problem.
View user's profileFind all posts by ruslanbesSend private message
Debugging requests from one host to another in CLI mode


Joined: 28 Sep 2013
Posts: 84
Location: Pantin, IDF, France
Reply with quote
Hello,

I have the same problem, but this solution doesn't work for me as I am debugging in CLI (Command Line Interface) mode.
How can I send DBGSESSID in CLI mode ?

Gingko
View user's profileFind all posts by GingkoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
PhpED supports remote debugging. Just run Project Settings Wizard, pick settings for your projects and it will run CLI php with debugger in the IDE. Remotely.
If you want to do this manually, there are two FAQ pages explaining options:
http://www.nusphere.com/kb/technicalfaq/howto_run_dbg.htm
http://www.nusphere.com/kb/technicalfaq/faq_dbg_related.htm

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 28 Sep 2013
Posts: 84
Location: Pantin, IDF, France
Reply with quote
dmitri wrote:
PhpED supports remote debugging. Just run Project Settings Wizard, pick settings for your projects and it will run CLI php with debugger in the IDE. Remotely.
If you want to do this manually, there are two FAQ pages explaining options:
http://www.nusphere.com/kb/technicalfaq/howto_run_dbg.htm
http://www.nusphere.com/kb/technicalfaq/faq_dbg_related.htm
Yes, but for several reasons (like willing to change command line arguments very often, which is cumbersome from the launch box, but also because the integrated console is quite painful to clear or reset between each run), I like to launch the software from an external console (generally PuTTY, and possibly from another computer, virtual or not), include a DebugBreak() and debugging with PhpED starting from there.

How can I do this (in CLI mode) without getting a message like “New debug session with [any file].php has started. But IDE could not find the project for the web debugging. Breakpoints and other features may fail to work”?

Gingko
View user's profileFind all posts by GingkoSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Gingko wrote:

How can I do this (in CLI mode) without getting a message like “New debug session with [any file].php has started. But IDE could not find the project for the web debugging. Breakpoints and other features may fail to work”?


You're getting this message because you don't have a project that matches the debug session parameters -- such as path, url, etc.
The easiest way to setup such project is to run Project Settings Wizard, like I said before.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 28 Sep 2013
Posts: 84
Location: Pantin, IDF, France
Reply with quote
dmitri wrote:
Gingko wrote:

How can I do this (in CLI mode) without getting a message like “New debug session with [any file].php has started. But IDE could not find the project for the web debugging. Breakpoints and other features may fail to work”?


You're getting this message because you don't have a project that matches the debug session parameters -- such as path, url, etc.
The easiest way to setup such project is to run Project Settings Wizard, like I said before.
I do have a project that matches the debug session parameters.

And I have run the Project Settings Wizard, and again, again, again, again, again, and again without any error.

But I must admit that this project doesn't match the debug session parameters about URLs.

Php CLI scripts do not have URLs.

Gingko
View user's profileFind all posts by GingkoSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
On Windows with IP address xxx.xxx.xxx.xxx have PhpED running with the project open. That PhpED can save directly to the storage area (eg on Linux using Samba) if appropriate.

You can have PhpED breakpoints in the script but they won't activate until after the first DebugBreak.

In the PHP CLI script use DebugBreak('1@xxx.xxx.xxx.xxx');

When the script runs (eg on Linux), it will hit the DebugBreak, the PHP debugger will contact the debug listener on the Windows computer and that will then activate PhpED. When you continue running (or single step) the script from PhpED, it will then be able to send the other breakpoints to the PHP debugger.
View user's profileFind all posts by plugnplaySend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
OMG, PhpED supports remote projects for 10 years now. Why don't you just try that? You don't need any DebugBreak(s), you don't need any Sambas, you don't need any dances with permissions and hardlinks.

Gingko wrote:

And I have run the Project Settings Wizard, and again, again, again, again, again, and again without any error.


Getting it passed without errors is not a goal. The goal is to run it in the project besides your files, then save the results discovered by the IDE in the process.
If after that you still get error like "new debug session started and project not found", please post all details here (or upgrade to PRO version and contact support)

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Debugging requests from one host to another
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 2  

  
  
 Reply to topic