Skip to content

WIFI can no longer use hostname in HTTP URL #9712

Closed
@thammr

Description

@thammr

Board

ESP32S2 Development Board

Device Description

ESP32S2 Development Board

Hardware Configuration

Two VL53L1Xs

Version

v3.0.0

IDE Name

Arduino IDE

Operating System

Windows 11

Flash frequency

OTA

PSRAM enabled

no

Upload speed

N/A

Description

My ESP32S2 POSTs a data packet to InfluxDb every 30-40 seconds. After recompiling my code today, now POSTing the data fails after about 5-7 packets. Wireshark shows that the ESP32 starts trying to send packets to 0.0.0.0. However, if I replace hostname with the IP, everything works fine. While the ESP32S2 is failing to POST data to InfluxDb, all the other networking stuff works OK- MQTT, OTA, ping.

The board manager shows version 3.0.0-rc3. I tried downgrading to rc2 - same result, Downgraded to 2.0.16 - works OK now.

I have at least 6 ESP32s sending data to InfluxDb without problem. All use hostname in the URL.

uri = String("http://") + host + ":8086/api/v2/write?org=" + org + "&bucket=" + bucket + "&precision=s";

The following code running on a Tiny Pico starts returning -1 after several minutes, Some time later, it will start returning a valid status (405 in my case). This pattern repeats.

Sketch

#include <WiFi.h>
#include <HTTPClient.h>
#include "arduino_secrets.h"

String postData = "Hello";
String url = "http://myhost:8080/";

void setup() {
  Serial.begin(115200);
  delay(2000);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print('.');
    delay(1000);
  }
}


void loop() {

  WiFiClient client;
  HTTPClient http;

  http.begin(client, url);

  http.addHeader("Content-Type", "text/plain; charset=utf-8");
  http.addHeader("Content-Length", String(postData.length()));
  int statusCode = http.POST(postData);
  
  http.end();
  Serial.println(statusCode);
  delay(1000);
}

Debug Message

N/A

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions