IoT with Packetriot Local Tunnel

One solution to expose your locally developed website or web application is to use local tunnel. Here an example is provided how you can do this. Here ESP8266 NodeMCU controlling a DC motor via local wifi web app running on local XAMPP based apache server is used as an example. The DC motor IoT web application once tunneled onto the internet can be controlled from anywhere in the world. Thus this is one example of internet of things(IoT). To do this we need a local tunnel provider. Here we will use Packetriot.

Following are the steps.

1. Sign up, download and install packetriot client 

Sign up at, https://packetriot.com

Visit the following url link and download and install packetriot client for your OS(here window is used)

https://packetriot.com/downloads

 2. Open CMD and start the packetriot client

First we have configure the packetriot connection. For this we type in the following command.

D:\User\pkriot-0-13.2>pktriot configure

This creates a config.json file in your computer that contains connection and authentication information which is located at C:\User\USERNAME\.pktriot\config.json in wiindows.

After that you need to provide the input selection id which in which of window is just the path to the above config.json file and for this we need to enter 1. Once 1 is entered you need to enter your credentials which is the email address you signed up with and the password used for packeriot signup. Next you have to select the regional server you want to use by hitting the option provided id number.

This all is shown below.

Then you will see domain name provided for you which in this case is goofy-dew-71866.pktriot.net, the server and the server IP address. You can also print the same information in the future if you need by typing the following command.

D:\User\pkriot-0-13.2>pktriot info

In the paketriot webpage in the tunnel section you can see the same updated information.

So we have one tunnel which is unnamed right now. We can change the name of this tunnel using the following command.

D:\User\pkriot-0-13.2>pktriot edit --name "iot"

Here we have provided iot as the tunnel name. On the packetriot dashboard you will see the tunnel name updated as shown below.

3. Check Tunnel working or not

We can check whether the tunnel is created or not by typing in first the following command.

D:\User\pkriot-0-13.2>pktriot start

You will see message that the HTTP services is running if successful.

Then in the browser type in the domain name provided to you which in this example is goofy-dew-71866.pktriot.net and you will see the following webpage which means that the tunneled domain name is working.


4. Local Tunnel

Here we have two options- Instant Hosting and Persistent Hosting. The instant hosting is used for just checking your locally developed sites and web applications. The persistent hosting is also used for website and web application feasibility but it comes with traffic rules functionality which does not require the user to re-enter traffic rules which is required in hosting scenarios. Also persistent hosting allows user to setup password protection on HTTP/S services, Let's Encrypt certificate management, firewall rules and more.

Instant Hosting example:

If we type the following command then we can tunnel our locally developed website/web application on the internet.

D:\User\pkriot-0-13.2>pktriot http 80

If connection successful then you should see the following in the cmd prompt.


 Then if you go to the domain name https://goofy-dew-71866.pktriot.net you should see your local webpage. 

This simple IoT based webpage is running on XAMPP Apache web server locally on the computer. So you have have local webpage running on your computer. See How to host website from home tutorial on how to setup XAMPP server at home to provide IoT services. The above webpage was developed for IoT service from home tutorial WiFi controlled DC motor with ESP12E.

Persistent Hosting example:

If we type the following command then we can tunnel our locally developed website/web application on the internet.


D:\User\pkriot-0-13.2>pktriot tunnel http add --domain goofy-dew-71866.pktriot.net --destination 127.0.0.1 --http 80

In the above command we have used 127.0.0.1 or localhost for internal IP address. But we can also use static IP address such as 192.168.1.2 for which we have configure in the router the IP address first and then write the following.


D:\User\pkriot-0-13.2>pktriot tunnel http add --domain goofy-dew-71866.pktriot.net --destination 192.168.1.5 --http 80

Then start the server

D:\User\pkriot-0-13.2>pktriot start


So in this way we have successfully created a tunnel and exposed our local web app on the internet. However we have used the sub-domain name provided by packetriot. You can use custom domain with packetriot.

Post a Comment

Previous Post Next Post