Posted on Sat, 20 May 2017
Using sshreach.me to test your webhooks
One of the often overlooked but very useful features of sshreach.me is the ability to use it to develop and test webhooks in your web app while it is still on your dev computer and behind a firewall. Let me show you how, using an example.
Suppose you develop a web application and in your web app you want to use PayPal’s services to allow your customers to buy your goods or services. During development you will, of course, use PayPal’s sandbox site where you can simulate and test the process of transferring funds from your customers to you. One of the mechanisms through which PayPal informs you of the money transfer is web notifications (in PayPal’s case they can be called webhooks or IPN or PDT API-s, but the process is similar). Simply said, web notifications or webhooks are special URLs in your web app, through which PayPal informs you of any changes in your account.
Testing those webhooks can present a challenge since your development computer is probably behind a firewall. If you have a static IP, you could probably set up port forwarding on your firewall, but it would mean that your dev environment is constantly open to the world; or, if you do not have a static IP, you would probably need to set up a sandbox server which has to be publicly accessible, and then transfer your dev environment to that server and then push changes from your computer to the testing server every time you make changes to the webhook code. This can become annoying very quickly.
With sshreach.me, you can just tunnel your development web server’s port through the sshreach.me’s tunnel and then set the PayPal’s notification URLs to the appropriate tunnel exit point. Furthermore, you can open and close the tunnel whenever you need to, so your development server is not visible on the whole internet all the time.
First, just create a new client and forward port number 80 (or whatever your dev server is listening to).
Once the client is created, you can find the entry point on the Info tab (for example: fw1.sshreach.me:10233)
All you need to do now is set up your PayPal’s notification URLs using the above info. For instance, to set up your PDT listener URL, like in this example:
And to set up your IPN listener URL:
Once these settings are saved, you can just open the tunnel and begin testing. When you are sure everything works properly, just close the tunnel and that’s it. Happy coding!