Issue with Web.Get - But WebViewer works (linking to an Arduino)

Hello!

I'm fighting to make work the Web response. I always have the "Error 1101: Unable to get..."
I'm using my cellphone, with the AI Companin option. Not the emulator.

The block is pretty easy:


image

What is strange is with WebViewer works great, it receives fast the answer from the WebServer (Arduino with ESP8266).
image

The same if I go to the browser and enter the same URL:
"http://192.168.0.77/val/Home_date?"

image

I also receive the Get action from the Web component.

So I don't know what to try. I'm connected in the same Wifi network, and I know the code in server is fine because it answer fast the get from the browser and Web.Viewer.

Any Idea to help?

Thanks

Can you turn off your phone's cell connection, so it only uses WiFi?

Your cell provider's ISP can't reach your local 192.168... address.

Done! and the issue remains.

WebViewer from my phone and Browser (from my PC and my Phone) works fine.
Get request from Web component reachs the WebServer.

What is the Home_date code?

Try
http://192.168.0.77/val/Home_date

I already try without "?" at the end. I'm using an specific caracther at the end to cut the string (msg) and make simple to answer specific data.

This is my arduino Code in that section:

    if(Serial1.find("+IPD,")){
            delay(1000);    
          connectionId = Serial1.read()-48; // Restar 48 porque la función read () devuelve 
          msg = Serial1.readStringUntil('?');
          ComSerial(connectionId, msg);    
     }

void ComSerial (const int connectionID, String msg){
         
     Serial.print("\n Mensaje Recibido:");
     Serial.print(msg);
     Serial.print("- fin mensaje\n");
           
     if (msg.endsWith("/val/Home_date"))
     {
     webpage =  String(now.day(), DEC) + "/" + String(now.month(), DEC)+ "/" + String(now.year(), DEC);
     Serial.print(webpage);
     sendData("AT+CIPSEND=" + String(connectionId) + "," + webpage.length() + "\r\n", 1000, false);
     sendData(webpage, 1000, true);
     sendData("AT+CIPCLOSE=" + String(connectionId) + "\r\n", 1000, true); 
     return;
     } 
     sendData("AT+CIPCLOSE=" + String(connectionId) + "\r\n", 500, false);          
}        

String sendData(String command, const int timeout, boolean debug)
{
    String response = "";
    Serial1.print(command); // Se envía el carácter de lectura a la esp8266
    long int time = millis();
    while( (time+timeout) > millis())
    {while(Serial1.available())
      { 
        char c = Serial1.read(); // Lee el siguiente carácter.
        response+=c;
      }  
    }
    
    if(debug)
    {
      Serial.print(response);
    }    
    return response;
}

This is what I see in the Serial Monitor:

image

It's the same answer as the WebViewer and Browser that works.
The text between: "Mensaje Recibido:" and "- fin mensaje". Is for debug.

21:54 is the actual time, that I want to response to the GET.

What it's difference regarding WebViewer is the number before :GET
In Web= 178, in Viewer=551.

Try to get response from Google.com and see what happens.

if (msg.endsWith("/val/Home_date"))

Change...

if (msg.indexOf("Home_date") >= 0)

What model of ESP8266 do you have? ESP8266-1, ESP8266-12E?

http://kio4.com/arduino/307_esp8266_PaginaWeb_Alea.htm

Thanks for both answer!

@vknow360: I tried with Google.com and the Web1 receive the info perfectly. So the issue is on WebServer side.

@Juan_Antonio: I will try that, but in the last test I remove the if to answer date info, always. And it didn't work. My ESP8266: ESP01S.
Your example is with an 8288, I'm not using any ESP8266.Wifi library

I believe I have to answer in a different ways if it's WebViewer and a differente way if its Web. Because answering the same way to both, Get it's not working.

Update:

I was able to make it work!
the issue was regarding the answer structure. I change to this and it started working good:

 // HTTP Header
     httpHeader = "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=UTF-8\r\n"; 
     httpHeader += "Content-Length: ";
     httpHeader += content.length();
     httpHeader += "\r\n";
     httpHeader +="Connection: close\r\n\r\n";
     httpResponse = httpHeader + content + " "; // There is a bug in this code: the last character of "content" is not sent, I cheated by adding this extra space
     sendData ("AT+CIPSEND=" + String(connectionId) + "," + httpResponse.length() + "\r\n", 500, true);
     sendData (httpResponse,1000,true);
     //sendData ("AT+CIPCLOSE=" + String(connectionId) + "\r\n", 1000, true);

Thanks for the Help :slight_smile:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.