Skip to content
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

HTTPClient doesn't respect CNAME TTL #9123

Open
5 of 6 tasks
oSquat opened this issue Apr 12, 2024 · 0 comments
Open
5 of 6 tasks

HTTPClient doesn't respect CNAME TTL #9123

oSquat opened this issue Apr 12, 2024 · 0 comments

Comments

@oSquat
Copy link

oSquat commented Apr 12, 2024

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: ESP8266
  • Core Version: ??? Arduino IDE 2.3.2 2024-02-20T09:54:08669Z ???
  • Development Env: Arduino IDE
  • Operating System: Debian 11

Settings in IDE

  • Module: Wemos D1 mini (clone)
  • Flash Mode: ???
  • Flash Size: ???
  • lwip Variant: ???
  • Reset Method: ???
  • Flash Frequency: ???
  • CPU Frequency: ???
  • Upload Using: Serial
  • Upload Speed: 921600

Problem Description

I am sending web requests to systems which are configured for failover using CNAME records with low TTL values which point to A records with higher values. For example, I have 4 DNS records:

  • myproject.example.com CNAME TTL 60 -> node1.example.com (primary)
  • myproject.example.com CNAME TTL 60 -> node2.example.com (secondary)
  • node1.example.com A TTL 86400 203.0.113.1
  • node2.example.com A TTL 86400 198.51.100.2

I am expecting the TTL of both records to be respected. When the CNAME expires a new lookup should be performed.

In practice, the esp8266 library appears to ignore the CNAME TTL and a new lookup is performed only when the underlying A record expires.

Sketch

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

void setup() {
  WiFi.begin("TheSSID", "ThePSK");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print('.');
  }
}

void webRequest() {
  WiFiClient client;
  HTTPClient http;
  if (http.begin(client, "http://myproject.example.com/useful_endpoint/")) {
    int httpCode = http.GET();
    if (httpCode > 0) {
        Serial.printf("[HTTPS] GET status code: %d\n", httpCode);
    } else {
        Serial.printf("[HTTPS] GET failed; status code: %d)\n", httpCode);
    }
    http.end();
  } else {
    Serial.print("connection failed");
  }
}

void loop() {
  delay(5000);
  webRequest();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant