2

I am currently developing an IOT device that can connect to the internet but works offline as well.

I have designed it so that when the user first connects to the wifi network run on the microcontroler, with his iphone, a browser window automaticly opens that displays the folowing html:

<!DOCTYPE html><html><head></head><body>
   <p><a href='http://samplepage.local:8000'>click here if the portal doesnt load</a></p>
   <script>location.replace('http://samplepage.local:8000')</script>
  </body></html>

on windows this connects to a site called "www.msftconnecttest.com", but on IOS it opensin the captive portal browser in the setings menu. I can get browsers to open it with this code:

if (client) {
String currentLine = "";
if (client.connected()) {
    for(int i = 1; i<3000; i++){  
  if (client.available()) {
    char c = client.read();
    if (c == '\n') {
      if (currentLine.length() == 0) {
        client.println("HTTP/1.1 200 OK");
        client.println("Content-type:text/html");
        client.println();
        client.print(responseHTML);
        break;
                                    } 
      else {currentLine = "";}
    } else if (c != '\r') {currentLine += c; }
  }}}
client.stop();

}

The purpose of this website is only to automaticly redirect the user to the ACTUAL webpage, which is http://samplepage.local:8000 (on port 8000). Idealy the user will never see this page except maybe for a split second, and if it gets stuck on it for some reason, he can just press the url to redirect to the real page.

This works flawlessly on both android and windows, regardless of browser. However, on IOS (any iphone i have tried from 5S to 11) it only shows the initial capture page shown above, where even clicking the url doesnt work. If i then go to safari and manualy enter http://samplepage.local:8000 ,it doesnt want to connect to it as well.

for some extra info, the device which i am connecting to (ESP32 microcontroler), serves also as a DNS server and a wifi station and access point. the network setings, as shown on the ipohne are the folowing: ip adress: 8.8.4.7 netmask: 255.255.255.0 router: 8.8.4.4. DNS: 8.8.4.4.

this is when the device is not connected to the internet. when it is connected to the internet it leases out a more normal IP adress like 192.168.0.3.

Would this be an iphone or a safari problem? does the iphone have any logs i can check for clues? Does ios have some extra security limitations that prevent these kinds of pages being loaded?

edit:

7
  • 1
    "when the user first connects to the wifi network" -- Does that mean that your device is connecting to a wifi network or that the iphone is connecting to your device's hub? Commented Sep 2, 2021 at 11:02
  • 1
    When the browser window automatically opens and displays the HTML, what mechanism powers that? What is the address of that page? Why do you need to redirect away from it? Commented Sep 2, 2021 at 11:03
  • i have edited the post for some extra clarification Commented Sep 2, 2021 at 12:14
  • Do you have DNS logs and HTTP logs on your device that you can consult? Does the iphone query the DNS server? Does it connect to the web server? Commented Sep 2, 2021 at 12:23
  • yes, it does connect to the wifi, and it also servers the iphone the html of the capture portal. Where could i check these DNS or http logs on the iphone? the server doesnt tell me much other then the device has conneced to it. Commented Sep 2, 2021 at 13:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.