Shane Angle
Posts: 29
Joined: Tue Apr 03, 2018 5:55 am

Node-Red and the local browser

Tue Apr 03, 2018 6:06 am

I am fairly new to coding and raspberry pi but I believe I have an issue probably someone has already encountered. I have a tcp/ip 8 channel relay that id like to run from my rj45 port of my pi (I have already set the ip for the eth0 for the network of the relay) I can run this relay inside the pi web browser but id like to control it with the server and cant <a ref "relay address in my html code for my site because it is not on my home network... Also I have a web cam set up on port 8081 but id like to also view this outside my network ANY SUGGESTIONS?

User avatar
topguy
Posts: 4552
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Node-Red and the local browser

Wed Apr 04, 2018 1:03 pm

ANY SUGGESTIONS?
Port-forwarding in your home-router/modem.

Shane Angle
Posts: 29
Joined: Tue Apr 03, 2018 5:55 am

Re: Node-Red and the local browser

Wed Apr 04, 2018 3:30 pm

I have done this also tried port forwarding 8081 in addition to 8080 but that was an invalid port

User avatar
topguy
Posts: 4552
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Node-Red and the local browser

Thu Apr 05, 2018 11:26 am

So explain exactly how you did the portforwarding and also include the HTML code you included in your external site to test this.
How did you test and how did it fail ?

Shane Angle
Posts: 29
Joined: Tue Apr 03, 2018 5:55 am

Re: Node-Red and the local browser

Sun Apr 15, 2018 1:01 am

<SCRIPT>
function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == "raspberry") {
alert('You Got it Right!');
window.open('www.raspiaddress/8081');
break;
}
testV+=1;
var pass1 =
prompt('Access Denied - Password Incorrect, Please Try Again.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3)
history.go(-1);
return " ";
}
</SCRIPT>
<CENTER>
<FORM>
<input type="button" value="Enter Protected Area" onClick="passWord()">
</FORM>
</CENTER>

User avatar
DougieLawson
Posts: 33018
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Node-Red and the local browser

Sun Apr 15, 2018 8:08 am

Shane Angle wrote:
Sun Apr 15, 2018 1:01 am

Code: Select all

window.open('www.raspiaddress/8081');
Replace that line with

Code: Select all

window.open('http://raspberrypi.local:8081/')
https://en.wikipedia.org/wiki/URL#Syntax
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

User avatar
topguy
Posts: 4552
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Node-Red and the local browser

Sun Apr 15, 2018 10:24 am

Dougie probably did not read the whole thread again and didn't realize that the page is hosted on external server.
He is correct that your format was slightly wrong. You should have "http://" in front and the portnumber needs to be preceded with ":", but "raspberrypi.local" only work on your LAN.

Code: Select all

window.open('http://123.123.123.123:8081');
If you goggle "what is my ip" from any conputer inside your LAN you should get the ip-adress to replace "123.123.123.123".
But the final little hurdle is that you probably can not test this from inside the LAN, using your external IP-address from inside confuses most home routers.

So to verify that the portforwarding is working you can check from the webpage http://canyouseeme.org/
But to test the hosted page properly you have to use a browser on a phone not connected to your wifi but via GSM network or from work or from a friends house.

Shane Angle
Posts: 29
Joined: Tue Apr 03, 2018 5:55 am

Re: Node-Red and the local browser

Mon Apr 16, 2018 5:45 pm

PERFECT!!!! its working now I just had to change my pi address to my web address. Thanks a bunch for the info :D :D :D :D c

Return to “Off topic discussion”

Who is online

Users browsing this forum: No registered users and 9 guests