NGROK Tutorial

darant1979
Posts: 13
Joined: Fri Jul 12, 2019 10:34 am

Re: NGROK Tutorial

Post by darant1979 » Thu Oct 01, 2020 9:58 am

I have been using NGROK for a while but the Android app will still not detect the alerts ... Unsure if that is the NGROK or the App.

When I run the BI remote wizard, the second from last step never connects.

I suspect this is the part that BI needs to sent the alerts to my phone.

The device is in, the Device tags are the same but it just will not send to the app.
montman2k
Posts: 4
Joined: Tue Nov 24, 2020 6:27 pm

Re: NGROK Tutorial

Post by montman2k » Tue Nov 24, 2020 6:36 pm

Thixotropic wrote: Fri Sep 18, 2020 8:06 pm It may be in the registry.

I'm new here and have looked over your post as I don't want to pay the 99 dollar reg fee again

So you are correct it is in the registry ..the only issue I am having is if my app is set to auto grab it wont connect even though the proper url is in the wan field.

I made a powershell script to modify the entry on startup and it propagates to the app, but if the check on every login is set in the app it wont connect unless I go into blue iris and remove or change a character and click ok in the ui.

Not being able to have it auto pull every time on its own defeats the purpose...this may be an issue to bring up to support as it may just be a function they need to call on start of the blue iris service to make it work as if I clicked ok.


If I turn off auto check lookup key on login and manually do it, it works fine.
montman2k
Posts: 4
Joined: Tue Nov 24, 2020 6:27 pm

Re: NGROK Tutorial

Post by montman2k » Tue Nov 24, 2020 10:51 pm

I was able to automate the process with powershell...I used Fiddler to see what what being sent to blue iris....I had to trim the string to remove the trailing CRLF. I will share if anyone is interested along with somewhat of a tutorial. It works with the auto grab url option checked.
User avatar
Thixotropic
Posts: 659
Joined: Wed Sep 04, 2019 7:20 pm
Location: Low-Earth Orbit

Re: NGROK Tutorial

Post by Thixotropic » Wed Nov 25, 2020 8:34 pm

Yes, please do share what you have, I'm sure it'll help others looking for answers.
Blue Iris 5.x x64 | Windows 10 Pro x64 | 16GB RAM | i7-7700 3.6 GHz | 1TB HDD | 2TB RAID NAS | 9 Cameras | Almost Dual NIC | 2KVA UPS
montman2k
Posts: 4
Joined: Tue Nov 24, 2020 6:27 pm

Re: NGROK Tutorial

Post by montman2k » Thu Nov 26, 2020 2:51 pm

So the Powershell Script is as follows since the forum wont let me post a zip ,just open powershell ise as admin and paste this in and modify as needed:
#Set Your Ngrok Parameters Here#
$filepath = 'c:\ngrok\ngrok.exe'
$args = 'http 127.0.0.1:9880'

Start-Process $filepath $args

timeout 10
#jqwin-64 path needs to match#
cmd /c curl -s localhost:4040/api/tunnels | c:\ngrok\jq-win64 -r .tunnels[0].public_url > C:\ngrok\NgrokURL.txt ##Adjust path as needed##
timeout 5
$filecontent = [IO.File]::ReadAllText("c:\ngrok\NgrokURL.txt")
$regkey = "HKLM:\Software\Perspective Software\Blue Iris\server" #This is correct for version 5#
$regprop = "ip"
$NewString = $filecontent -replace ".*//"
$NewString = $NewString.Trim()
if(Test-Path ($registryPath + "\" + $regprop))
{
New-ItemProperty -Path $regkey -Name $regprop -Value $NewString
}
else
{
Set-ItemProperty -Path $regkey -Name $regprop -Value $Newstring
}
Restart-Service -Name BlueIris #Optional if this process runs before blue iris

So essentially what this does is run the ngrok process with the parameters you specify in the $args field and then extracts the url from the ngrok api and transposes it to a text file, removes the trailing CRLF and then modifies the registry as well as restarts the service if its running to allow Blue iris to update.(Note this can also just be done opening console and closing it from powershell as well) Also this doesn't kill the ngrok process if its already running but it will still pull the existing tunnel info .

I did this very quickly so I know it isn't the best thought out / looking code but it works for what I need it for. If you already have a ngrok task, you could remove the items above and including start process to treat this as a seperate item.

you do need jq for windows available at https://stedolan.github.io/jq/ and this file placed in the path specified in the powershell.

For the scheduled task run as Admin, the following is what you need..obviously paths and names change as needed:

Powershell.exe

Arguments -ExecutionPolicy Bypass -command "c:\ngrok\ngrokfree.ps1"

Also in Blue Iris uncheck the auto update checkbox under the wan field so it doesn't populate the ip automatically.

That's all there is to it.


If Anyone has any questions I'd be more than happy to help out.
User avatar
Thixotropic
Posts: 659
Joined: Wed Sep 04, 2019 7:20 pm
Location: Low-Earth Orbit

Re: NGROK Tutorial

Post by Thixotropic » Fri Nov 27, 2020 4:01 pm

Awesome, thank you. I'm sure this will help some people who are also trying to puzzle this out.
Blue Iris 5.x x64 | Windows 10 Pro x64 | 16GB RAM | i7-7700 3.6 GHz | 1TB HDD | 2TB RAID NAS | 9 Cameras | Almost Dual NIC | 2KVA UPS
Post Reply