I tried to make a small Server with Esp8266. If i pot the port in "WiFiServer server();" to 80 i can access the site from my local WiFi if i change it e.g. to 88 there is no chance to access it.
Now opened port 8080 to 80 (or whatever to what i set up) on my router. If i use this Open Port Check Tool - Test Port Forwarding on Your Router to check wehter the port is open it say yes and i see it in the serial monitor that something connected. Also when it is a different port then 80. So in conclusion I can access the site from my local network just on port 80 and never from outside just the website can.
Why? ;(( its so weird
/*#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
// Replace with your network credentials
const char* ssid = "Hybrid2017";
const char* password = "*****";
*/
#include <ESP8266WiFi.h>
const char* ssid = "Hybrid2017";
const char* password = "2193907354499390";
WiFiServer server(80);
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println(" connected");
server.begin();
Serial.printf("Web server started, open %s in a web browser\n", WiFi.localIP().toString().c_str());
}
// prepare a web page to be send to a client (web browser)
String prepareHtmlPage()
{
String htmlPage =
String("HTTP/1.1 200 OK\r\n") +
"Content-Type: text/html\r\n" +
"Connection: close\r\n" + // the connection will be closed after completion of the response
"Refresh: 10\r\n" + // refresh the page automatically every 5 sec
"\r\n" +
"<!DOCTYPE HTML>" +
"<html>" +
"Analog input: " + String(analogRead(A0)) +
"</html>" +
"\r\n";
return htmlPage;
}
void loop()
{
WiFiClient client = server.available();
// wait for a client (web browser) to connect
if (client)
{
Serial.println("\n[Client connected]");
while (client.connected())
{
// read line by line what the client (web browser) is requesting
if (client.available())
{
String line = client.readStringUntil('\r');
Serial.print(line);
// wait for end of client's request, that is marked with an empty line
if (line.length() == 1 && line[0] == '\n')
{
client.println(prepareHtmlPage());
break;
}
}
}
delay(1); // give the web browser time to receive the data
// close the connection:
client.stop();
Serial.println("[Client disonnected]");
}
}
I tried to make a small Server with Esp8266. If i pot the port in "WiFiServer server();" to 80 i can access the site from my local WiFi if i change it e.g. to 88 there is no chance to access it.
Now opened port 8080 to 80 (or whatever to what i set up) on my router. If i use this Open Port Check Tool - Test Port Forwarding on Your Router to check wehter the port is open it say yes and i see it in the serial monitor that something connected. Also when it is a different port then 80. So in conclusion I can access the site from my local network just on port 80 and never from outside just the website can.
Why? ;(( its so weird
If you want to have a thread moved to a different forum section you can click the "Report to moderator" link at the bottom of the post and ask nicely for it to be moved. However, it's better to take the time to find the best forum section before posting because the moderators already have plenty of work dealing with spam.
Making it accessible from outside your LAN involves changes to your router. If you say that that you see something in the serial monitor when connecting from outside can you please post it (use the code tags).
AlexTest:
Hey guys im very frustrated at the moment.
I tried to make a small Server with Esp8266. If i pot the port in "WiFiServer server();" to 80 i can access the site from my local WiFi if i change it e.g. to 88 there is no chance to access it.
Now opened port 8080 to 80 (or whatever to what i set up) on my router. If i use this Open Port Check Tool - Test Port Forwarding on Your Router to check wehter the port is open it say yes and i see it in the serial monitor that something connected. Also when it is a different port then 80. So in conclusion I can access the site from my local network just on port 80 and never from outside just the website can.
Why? ;(( its so weird
192.168.20.34:88
That is how you would gain remote access the http interface of the device assuming you have port forwarded correctly to port 88 in your ADSL modem settings. I.E. Local port should be 80 while the public access port should be 88.
Oh and replace '192.168.20.34' with what ever your public IP address as seen in your ADSL modem settings.
Thank you i was able to reach the site even when I switch the ports but I am still not able to reach ist from the outside. I set the server to 88 and on my router I selected the esp and tried 80 to 88 and 88 to 80 on TCP it did not work.
Another Question is there a good documentation of the wifif libraries (<ESP8266WiFi.h>,<WiFiClient.h>,<ESP8266WebServer.h>) with any other thing i came a head. But the wifi stuff is killing me right know.
and so much other stuff on which i cant find documentation. For a beginner with zero knowledge of networks, electronics and serve and programming it is pretty hard without a good documentation.
server.on("/inline", [](){
server.send(200, "text/plain", "this works as well");
});
The usual way to do this to use a real function.
void handle_inline() {
server.send(200, "text/plain", "this works as well");
}
...
server.on("/inline", handle_inline);
In the example, the author decided to demonstrate the way expert C++ coders avoid creating a short function by including the function body "inline" as a parameter to another function. Clever but obscure. This is not to be confused with the inline keyword. I think "" means create a function with no name and the body of the function follows. I am not a C++ expert so I am not sure what this is called. In Javascript, these are called anonymous functions.