-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Portmapping prohibits loading index.html #16
Comments
I think you are using port-forwarding via static IP at the router to access ESP8266 from WAN.
Yes, it redirects to /ac if the IP contained in the host header of the http request is different from the IP of ESP8266. This code corresponds to AutoConnect::_captivePortal(). AutoConnect/src/AutoConnect.cpp Line 439 in 3d0d397
But that logic is tied to the onNotFound of the base class ESP8266WebServer. Therefore I think that the base ESP8266WebServer library had not found the index.html. Can you access to /index.html on ESP8266 from WAN without AutoConnect? There may be some way if that is possible. Can you take a debug log HTTP_SERVER and AutoConnect? To enable debug log, activate Arduino-IDE option as Tools -> Debug Level -> HTTP_SERVER, Debug port -> Serial and AC_DEBUG in AutoConnect.h header, the debug log can be obtained by serial monitor. If you got a log in your environment I will consider a remedy.
|
Yes from wan i can access index.html without Autoconnect. I did some logging. I think the problem is with: Request: /index.html Part of Logging (changed my external ip address with 'my_external_ip'): bcn 0 New client New client |
It seems that /index.html was not found by the ESP8266WebServer class, and AutoConnect is redirecting to /ac of the local-IP on ESP8266. "request handler not found" is the behavior in ESP8266WebServer class. The request is my_external_ip:1036/index.html, but since this is not an AutoConnect page, ESP8266WebServer class will try to process it as it is. |
I suggest an additional idea. If you can access except for /index.html from WAN without AutoConnect, it might be able to use a way of giving static IP immediately after WiFi.begin with before WiFi.status check. Implement it in the AutoConnect::begin function. (or entrust it to the user sketch with a callback function.) |
Yes, without captive portal/AutoConnect my_external_ip:1036 redirects to my_internal_ip/index.html because i'm using I thought that |
Maybe before checking
If we're on lan, and only then, check wether we're on another domain. |
I understood your idea. So, please tell me
In such a case, did |
In my code i have:
My old code:
Tried your solution:
Yes, but this is not working. With portmapping i try to map my_external_ipaddress: cliënt on port 1036 to my_internal_ipaddress: server on port 80. When i submit my_external_ipaddress: port 1036 into a webbrowser while i'm on wan i notice the external_ipaddress: port 1036 changes into my_internal_ipaddress\index.html. I think it's because i'm on wan and my_internal_ipaddress is a private ipaddress this address can never be reached from wan. When portmapping is working correctly my index.html page can be reached at my_external_ipaddress:1036\index.html or my_external_ipaddress:1036 |
After the connection has been established, AutoConnect::handleClient() simply calls ESP8266WebServer::handleClient(). The sequence of control flow is as follows. AutoConnect::handleClient() -> ESP8266WebServer::handleClient() -> ESP8266WebServer::_parseRequest() -> FunctionRequestHandler::canHandle() -> FunctionRequestHandler::handle()/index.html The timing when control is passed to AutoConnect is after in handleRoot() "Location: http://local_ip/index.html" String location = String("http://") + server.client().localIP().toString() + String("/index.html"); "Location: http://external_ip:1036/index.html" String location = String("http://") + server.hostHeader() + String("/index.html"); Can the sketch make that judgment with |
I tried the above solution in my WAN environment, and it worked fine. I configured in my ISP router for port forwarding by static IP masquerade as like this: void handleRoot() {
String location = String("http://") + server.hostHeader() + String("/index.html");
server.sendHeader("Location", location, true);
server.send(302, "text/plain", "");
server.client().stop();
} |
I agree. Looking at my serial port i can see the following lines connecting from wan to lan:
One would expect index.html to be loaded. However this seems not to be the case. |
It means the value of the host header which the ESP8266WebServer class could not find the request handler before detecting AutoConnect handler. Looking at the log you provided, It has not found "/" as well. |
Perhaps, the cause is insufficient RAM for TCP stack. If your sketch is handing a large String directly to |
Tried an almost empty root page (/index.html). Same problem. So it's not size causing the problem. [AC] WiFi.config(IP=192.168.1.119, Gateway=192.168.1.1, Subnetmask=255.255.255.0, DNS1=192.168.1.5, DNS2=0.0.0.0) Starting the esp8266 without a wifi-connection my sequence is as follows:
|
Of course, AutoConnect handles the unhandled request of ESP8266Webserver. |
Closing due to lack of response. |
I'm using AutoConnect with static ip address. First starting with captive portal to obtain a dynamic ip-address. Then setting static ip address. It's working great, except for remote access to the index.html page on my esp8266.
While within my lan index.html can be reached direcly, from wan/internet/outside my lan it seems portmapping forces startup with captive portal, i.e. /_ac. Can this be fixed?
The text was updated successfully, but these errors were encountered: