NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Paypal IPN debugging using ngrok on localhost not triggered


Joined: 31 Oct 2012
Posts: 16
Location: Canada
Reply with quote
Hi.

I'm currently trying to debug Paypal IPN (Instant Payment Notification) on localhost. Since an external service cannot access localhost, I decide to use ngrok (https://ngrok.com) to be able to "expose" my localhost to the internet.
This little service is marvelous and my localhost is now indeed accessible from the internet. The problem I have is that I cannot trigger the debugger to start when it my php script is accessed (I've checked, using logs).

Here are the steps to reproduce

- Install and setup ngrok
- In cmd, cd to project directory and start a ngrok tunnel using this command: ngrok http -host-header=localhost:80 80
- Go to http://localhost:4040/ to click and display the ngrok local host Request Inspector Page.

Note: h-t-t-p stands for httpn, and .xxx.yyy is to hide my ip address Wink

Now you can go to your project page, just as if you were calling from inside your computer like this h-t-t-p://d84fe39b.ngrok.io/myProject/index.php.
h-t-t-p://d84fe39b.ngrok.io now represent localhost on your machine

When I use h-t-t-p://localhost/myProject/index.php, debugger is triggered
When I use h-t-t-p://d84fe39b.ngrok.io/myProject/index.php, debugger is NOT triggered

When I tried to add ?DBGSESSID=437615619354100004;d=1,p=0,c=1 in the url I received a debugger message, but no debugger triggered:

DBG 9.1.10

Failed to start DBG session

Reason: failed to connect to the client at 72.10.xxx.yyy:7869, please make sure that IDE is running
Not sure what it means? Visit http://www.nusphere.com/dbg/?err=-5 for troubleshooting.
If you didn't intend to run debug session you may want to drop debugger cookie by clicking this button:

Debugger request: "437607218943800003;d=1,p=0,c=1&id=111"
Request found in: "query_string"
Target PHP version: "5.6.x"
Server API: "Apache 2.0 Handler"
Extensions API: "220131226"
Modules API: "20131226"
PHP API: "20131106"

After reading all nusphere doc, I've tried everything with no success

Here is my php.ini debugger settings:

[debugger]
debugger.JIT_enabled=Off
debugger.JIT_level=3
debugger.hosts_deny=ALL
debugger.hosts_allow=127.0.0.1, localhost, ::1, 72.10.xxx.yyy
debugger.ports=7869

I have tried with or without 72.10.xxx.yyy but it didn't worked.

If I can't trigger debugging by simply calling index.php from ngrok, there is no reason to continue trying to debug Paypal IPN...

Does anyone has experience using ngrok with PhpEd, in debug mode?

If this works, It could open a lots of great opportunities for remote services call debugging...

Thanks
View user's profileFind all posts by fledSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Quote:
I have tried with or without 72.10.xxx.yyy but it didn't worked.


If I got you right, your web and IDE are on the same host. In this case you'd better add 127.0.0.1 in to the URL. Otherwise debugger "thinks" the IDE is where the client -- your ngrok and fails to reach out the IDE.[/quote]

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


Joined: 31 Oct 2012
Posts: 16
Location: Canada
Reply with quote
I have tried starting ngrok with this : ngrok http -host-header=rewrite 127.0.0.1 but still nothing works

The code executes but the debugger does not starts, with the same error message: Failed to start DBG session...

Does anybody have experiment with ngrok to give access to localhost to outside services?
View user's profileFind all posts by fledSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Sorry, I have no idea what ngrok is and what its role in this context.
What I meant is -- instead of the following HTTP GET parameter
Quote:
When I tried to add ?DBGSESSID=437615619354100004;d=1,p=0,c=1 in the url I received a debugger message, but no debugger triggered

you want to try ?DBGSESSID=437615619354100004@127.0.0.1;d=1,p=0,c=1

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


Joined: 31 Oct 2012
Posts: 16
Location: Canada
Reply with quote
Whoo-hoo! Its working!
Thanks Very Happy

As I mention before, ngrok is a tool that enables me to "expose" my localhost to the internet. The reason I'm using it is because I want to be able to debug the return of a Paypal transaction (IPN) in my development environment, not remotely on my production server.

So when I'm on Paypal Sandbox, after having started an ngrok session, I now use these parameters to create a transaction

// Debug to localhost using ngrok
$ngrokSession = 'http://604df65f.ngrok.io';
$DBGID = '?DBGSESSID=437607218943800003@127.0.0.1;d=1,p=0,c=1';
$TEST_URL = (SYST_WEB_ENVIRONMENT != 'dev') ? $ngrokSession . '/myLocalProjectDirectory' : 'http://dev.myproject.com'; // Local dev or remote dev

// PayPal settings
if ($isSandbox) { // Testing credentials

$business_email = "payment-facilitator@myproject.com";
$return_url = "$TEST_URL/myShoppingCart.php$DBGID&ctype=$cartType; // Also used to delete cart item after buying process
$cancel_url = "$TEST_URL/myShoppingCart.php$DBGID";
$notify_url = "$TEST_URL/_paypalProcess.php$DBGID";

}

With the new parameter you have proposed me (@127.0.0.1) its working properly and my debug session is triggered. Laughing

Now I will be able to debug any external services!

Thanks again Very Happy
View user's profileFind all posts by fledSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
FYI instead of exposing something with ngrok, which may be unsafe, you can debug your public or intranet web sites in-place -- see Remote project options in Project Settings Wizard

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


Joined: 31 Oct 2012
Posts: 16
Location: Canada
Reply with quote
Thanks but it is easier with ngrok (with the little trick you showed me).

Access to ngrok session address is not intuitive. This session number ('http://604df65f.ngrok.io') change every time you start a new session.

So it would be impossible for someone to guess it and access you localhost

The sessions can also be killed using Ctrl-C, when debugging is done, blocking all access to your computer,
and if you ever forget to kill your session, it will terminate itself after 8 hours
View user's profileFind all posts by fledSend private message
Paypal IPN debugging using ngrok on localhost not triggered
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 1  

  
  
 Reply to topic