I had a requirement that said sending out SMS messages which come delivery status. I was looking at Twilio and they provide status callback.
As you know that callback API must be standing out on public to receive requests from any 3rd party services and my local environment is sitting behind my home router which is private. The old fashioned solution would be a port forwarding but there’s the service called ngrok.
ngrok provides public URLs for exposing your local web servers, testing on mobile devices, building webhook/callback integration, etc. Good thing is free for 1 process, 4 tunnels, and 40 connections. That is enough for me for testing my implementation.
Once you created an account, you will see the instructions on the dashboard.
- Download and unzip the ngrok application on your machine.
- Connect your account.
$ ./ngrok authtoken XXXXXXXX
- Fire it up and Boom!
$ ./ngrok http 8000
Below is the screenshot.
ngrok by @inconshreveable (Ctrl+C to quit) Session Status online Account firstname.lastname@example.org (Plan: Free) Version 2.3.35 Region United States (us) Web Interface http://127.0.0.1:4040 Forwarding http://236168b0.ngrok.io -> http://localhost:9001 Forwarding https://236168b0.ngrok.io -> http://localhost:9001 Connections ttl opn rt1 rt5 p50 p90 18 0 0.00 0.00 0.03 10.48 HTTP Requests ------------- POST /notification/sms/callback/ 200 OK POST /notification/sms/callback/ 200 OK POST /notification/sms/callback/ 500 Internal Server Error POST /notification/sms/callback/ 500 Internal Server Error GET /notification/sms/callback/ 405 Method Not Allowed GET /notification/sms/callback/ 405 Method Not Allowed
Every time the ngrok runs, it generates the random computer name.
If you want a reserved address, you need to upgrade to one of paid account.
ngrok provides a real-time Web UI where you can introspect all of the HTTP traffic running over your tunnels. After you’ve started ngrok, just open http://localhost:4040 in a web browser to inspect request details.
There’s the button called Replay on the right top of the screen. This allows you to replay any request and also allows modifications.
- Easy to setup.
- Getting random IDs might be a silly dog. Feed him.
- Web UI for inspecting all traffics.