Pages: [1]   Go Down
Author Topic: Access ENC28J60 etherShield Outside Home Network  (Read 1066 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

I need your help on what I think is an simple problem.  I have a program working for my etherShield but not all of it works from outside my home network.  My program toggles a digital output from web.  My web page shows up onside my network, but the switch does not work.  I am using my public IP to see the webpage, and I forwarded port 80 to the internal IP of my etherShield.

Public IP example: 24.165.89.18:80
Internal IP of etherShield: 192.168.1.15

I see the webpage from outside my network, but it does not function.
help smiley-cry

Project Code: http://pastebin.com/90T5ginx

Web page code:
Code:
  int i=0;
 
 
  uint16_t plen;
 
 
 
  plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
  plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<center><p><h1>Welcome to the DBM Switch Controller </h1></p> "));
 
  plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr><br><form METHOD=get action=\""));
  plen=es.ES_fill_tcp_data(buf,plen,baseurl);
  plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("\">"));
  plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> REMOTE SWITCH: </h2> "));
  plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h1><font color=\"#00FF00\"> "));
 
  if(on_off)
    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("ON"));
  else
    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("OFF"));
 
  plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("  </font></h1><br> ") );
 
  if(on_off){
    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=3>"));
    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"Switch off\"></form>"));
  }
  else {
    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=2>"));
    plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"Switch on\"></form>"));
  }
 
 
  return(plen);
« Last Edit: February 07, 2013, 09:12:13 pm by dbmiller5 » Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11173
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Presumably the web page has a control that triggers an HTTP transaction of some sort?

I suggest you post the page source of a typical page so that we can see what it is supposed to do.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I put a link to my whole project code.  I also revised my post and added the code for the web page.  Thanks!
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8929
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I forwarded port 80 to the internal IP of my etherShield.

Some ISPs block port 80 access to home accounts to prevent commercial use. You might try another port.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11173
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I put a link to my whole project code.  I also revised my post and added the code for the web page.  Thanks!

Can you post the source of a sample web page, i.e. what the browser actually receives? I don't want to have to wade through the code guessing what it does. Most browsers provide a means to show the source of the currently loaded page. Just paste the source here, in CODE tags.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some ISPs block port 80 access to home accounts to prevent commercial use. You might try another port.
I tried this but it didnt work.  I could not even see the page using my wan IP and a random port.  I thought this was a good idea but...


Can you post the source of a sample web page, i.e. what the browser actually receives? I don't want to have to wade through the code guessing what it does. Most browsers provide a means to show the source of the currently loaded page. Just paste the source here, in CODE tags.

Good idea!
Code:
<center><p><h1>Welcome to the DBM Switch Controller </h1></p> <hr><br><form METHOD=get action="http://192.168.1.15/"><h2> REMOTE SWITCH: </h2> <h1><font color="#00FF00"> ON  </font></h1><br> <input type=hidden name=cmd value=3><input type=submit value="Switch off"></form>
« Last Edit: February 08, 2013, 09:32:58 pm by dbmiller5 » Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 89
Posts: 3480
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only IP address in that page source is the local address of your Arduino, should it not be the public address of your router ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The only IP address in that page source is the local address of your Arduino, should it not be the public address of your router ?

When I put my public IP in my code, I cannot connect to it from public or private lan.  When I put in the 192.168.1.X in my code, and use my public IP in browser, I can connect to it but other people cannot. 
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am still stuck on this problem.  Anymore suggestions would be appreciated.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would love some help, anyone?
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The action in your <form METHOD=get action="http://192.168.1.15/"> is called by the browser. It will work if the browser can access it (true from the local network only). Since you are using functions from the etherShield library you may be able to retrieve the address of the browser that is sending the request. Then, if it starts with 192.168 you know it's from the local network.

Once you know that, it is easy to change the value of your action so that it reflects the local / public address.

If you cannot get the remote address, your only option is to define different URLs for local and remote clients (e.g. http://192.168.1.15/local, http://your.public.ip/remote). You won't need to define two different pages, just parse the request to differentiate the value of the action.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11173
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You are setting the action attribute of the form to "http://192.168.1.15/" so of course that does not work from outside the local network. I guess you're processing the response in the same handler that supplies the original page, so you should be able to get rid of the action attribute completely; it will then default to the URI of the current page.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: