ok, so no luck. Here is my post:
I’m going through the “Access Your ESP32 Web Servers from Anywhere” module in the Build Web Servers eBook, and am having trouble connecting to the ESP32 via the ngrok url. I have 4 devices: the PC (used to sign up to ngrok, and shows the web page with Authentication token), a cellphone, an RPi B+, and an ESP32 with code (which works fine via the wifi local network). I have installed the ngrok s/w on the PC via the “Download for Windows” button and ran the .exe. I have pulled down RNT’s ngrokARM (using the wget command as indicated) into the RPi, and then on the RPi have saved the token using ./ngrok authtoken xxxxxx). Finally, I have done the “./ngrok http -auth=”mySSID:myPSWD” ip_adr_of_the ESP32:80″.
When I go to the PC (or cellphone) browser with https://xxxxxxx.ngrok.io, it comes up with: “Tunnel xxxxx.ngrok.io not found ERR_NGROK_3200″
If I again, on the RPI, do the ./ngrok http -auth=”mySSID:myPSWD” ip_adr_of_the ESP32:80 , it states:
Your account is limited to 1 simultaneous ngrok client session.
Active ngrok client sessions in region ‘us’:
– ts_yyyyyyyyyyyyy (then an IP adr here starting with 108.68…. ).
I have no idea what that IP adr is, but “tunnel not found” is what I’m trying to deal with. On the ngrok webpage on the PC, under Tunnel Agents/Status, it states “Access Requested Thank you for your interest. We’ll keep you posted regarding access to Tunnel Sessions”.
Any help would be appreciated. Thanks
I thought I solved this. The IP I was using was NOT the one listed as the Forwarding link after I did the “./ngrok http -auth=”mySSID:myPSWD” ip_adr_of_the ESP32:80” as stated in the eBook, but rather I found on the ngrok webpage under Endpoints/Status, the url to use to access the ESP32. Maybe they changed the s/w (or I’m not seeing something), but the description on pg 589 does not work.
However, rebooting the RPi, (which has the screen command in the .bashrc file), now there is nothing in the Endpoints/Status page of the ngrok page on the PC, and no URL yields anything but “Tunnel not found” again 🙁 (When the tunnel did work, the URL only worked on the PC and activated the LEDs on the ESP32. But doing it from the cellphone yielded an error …..) … more work to do …
Further update — after doing http -auth “mySSID:myPSWD” my_ESP_ip:80, and leaving the app up in RPi (i.e. don’t do a Ctrl-C, which I had been doing to get back to the terminal prompt) … using the forwarding URL in the PC (the same device being used for the SSH’ing), the ESP32 webpage comes up, and the RPi shows the GET’s of script.js and style.css. However, the sliders don’t work – this time they don’t change the LED ! … and putting the same forwarding URL into the cellphone results in “401 unauthorized. I wish their tutorials would help here – shouldn’t be rocket science to do this! (Once I ctrl-c out of the ngrok app in the RPi, the forwarding URL no longer works and states “Tunnel not found” …. so at least it’s getting clearer that the ngrok app has to be running (put the http -auth… in the .bashrc?), but why isn’t the websocket updating working to change the LED brightness?
The ngrok software needs to be running for you to access the web server. If you stop it with CTRL-C it will stop working, and the next time it goes on, it will have a different URL.
I’m sorry, but your description was very confusing. Have you tried to get some assistance from ngrok support?
Did you take a look at this: https://ngrok.com/docs?
Thanks Sara … yes a bit confusing – sorry. So, yes, I now know that ngrok must stay up – the webpage of the ngrok site does not show tunnels opened, as the eBook shows on pg 592, so the only way I know what the url is, is by keeping ngrok up and looking at the terminal display of RPi. (I suppose that when this app is auto-started in .bashrc or whatever, one has to do a grep/sed on the output to find the url and send it off via email or something, otherwise you have to keep the terminal up ….).
Just to be clear: the code I have in the ESP does the 3 slider LED with NotifyClients, and works fine via wifi.
So, the problem I’m having is that I now can access the ESP, and it provides the index.html page, and I see in the RPi ngrok terminal display that it is getting the script.js and favicon.png and style.css. But now via ngrok, the sliders move but the LEDs don’t change. (I can access the ESP via my iPhone, but again the sliders don’t affect any change) … seems the ESP is not responding to websocket onEvents or messages from the browsers. … any thoughts? (the serial monitor shows connect/disconnect messages, and just one startup, it shows data=103 (I put in a print statement in the case WS_EVT_DATA … no printout when move slider…. further info: in the browser console, when slider 1 is moved, it shows this:
Uncaught TypeError: websocket is undefined
(is ngrok worth pursuing? … versus firebase?)
I talked about this issue with Rui, and it said that ngrok had some issues with websockets previously.
The HTTPS link didn’t work with websockets. You needed to use HTTP. I don’t know if that’s still the case.
Some people prefer to manually open a port on their router to access the web server from anywhere. However, I don’t recommend doing that unless you know very well what you’re doing and be aware of security issues.
Firebase is great. And your web apps are automatically accessible from anywhere. But the way you program the ESP is different. In this case, the ESP is a client and Firebase is the server.
YES! … that did it! … using http instead of https makes it all work fine 🙂 .Thank you! So, it may not be the most secure option for remote access 🙁
The remaining issue is how to use ngrok. My ngrok logged-in web page does not offer a way to find out the link (as you show in the eBook). I have to find it on the RPi when I launch the ngrok http – auth ….. program. I know that a grep/sed script can be used to launch it and pull off the link. Is there something I’m missing? (maybe ngrok really wants a user to subscribe and pay for the service, then the links would appear in their web page?).
Thanks for the info on Firebase vs. ngrok. I guess the ESP can still be the server for other ESPs while being the client for Firebase. But is there some reason why being the client in Firebase is a limitation versus the ngrok method (I don’t like that I have to keep a RPi server on to service ngrok).
I have a free account on ngrok, and it shows the links. I don’t know if they updated something. Try to get help from their support and see what they recommend.
Hi Sara …. ok, finally understand what I need to do to get ngrok to work when a headless RPi reboots (which is a sensible design requirement) … this is my summary from your eBook and your help:
1. in the RPi, autostart ngrok http -auth etc. (using the linux screen function in the .bashrc file, for example or other methods like “run” service daemon which may be more reliable).
2. on the user’s ngrok webpage, go to the Endpoints / Status tab (not Tunnels or Tunnel Agents) to see the https and the http links that can be used to access the ESP.
3. use the http link, and not the https link. This means security is not optimal, but use a login procedure.
4. when the RPi reboots (for whatever reason – power outage, etc), one must find the new http link that was established. Go to Endpoints / Status to find them.
5. for the likely use of an iPhone shortcut, it will have to be modified if the RPi reboots …:-(
Thanks for your patience as I come to understand this application, and thank you for providing the eBook to learn a lot about web serving 🙂 … onto the Firebase eBook.
This post can be closed.