Skip to content

GET requests not work properly #6332

@dzmpr

Description

@dzmpr

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP-12E/NodeMCU v.10
  • Core Version: 2.5.2
  • Development Env: Platformio/ArduinoIDE
  • Operating System: Windows

Settings in IDE

  • Module: Nodemcu v1.0
  • Flash Mode: qio
  • Flash Size: 4MB
  • lwip Variant: v2 Lower Memory
  • Reset Method: nodemcu
  • Flash Frequency: 40Mhz
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 115200

Problem Description

When requests running with delay several seconds between on core 2.5.2 the data (received with .getString()) not modifying (with reuse set to true).
When I set reuse false - response just get w/o body. And every second response return -2 HTTP error code. In both situations script on server the same (obviously). And this problem doesn't happen on 2.4.2 core.
Here #6149 man stuck with the same problem, but no one respond.

MCVE Sketch

#include <Arduino.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>

BearSSL::WiFiClientSecure client;
HTTPClient https;

void setup() {
    Serial.begin(115200);
    WiFi.begin("ssid","pass");
    while(WiFi.status() != WL_CONNECTED) {
        Serial.print(".");
        delay(500);
    }
    Serial.println("\nWifi connected!");
    uint8_t cert[20] = {184,120,14,91,203,255,205,98,26,130,214,144,95,34,236,197,210,208,31,245};
    client.setFingerprint(cert);
    https.setReuse(true);
    https.begin(client, "https://link");
}

int code;
String response;

void loop() {
    code = https.GET();
    Serial.println("Code: " + String(code));
    response = https.getString();
    Serial.println("Body: " + response);
    delay(2000);
}

Debug Messages

##With reuse

Code: 200
Body: mode?a=16711680&b=2
Code: 200
Body: mode?a=16711680&b=2
Code: 200
Body: mode?a=16711680&b=2
Code: 200
Body: mode?a=16711680&b=2
@@@Here I change data in database, but messages below are similar to above.
Code: 200
Body: mode?a=16711680&b=2
Code: 200
Body: mode?a=16711680&b=2
Code: 200
Body: mode?a=16711680&b=2
Code: 200
Body: mode?a=16711680&b=2

##Without reuse

@@@Each other request get failed, and all requests return empty body.
Code: -2
Body:
Code: 200
Body:
Code: -2
Body:
Code: 200
Body:
Code: -2
Body:
Code: 200
Body:
Code: -2
Body:
Code: 200

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions