jdemaeyer / brightsky

JSON API for DWD's open weather data.
https://brightsky.dev/
MIT License
287 stars 18 forks source link

DNS Failed for https://api.brightsky.dev [E][WiFiGeneric.cpp:739] hostByName() #161

Closed MHz000 closed 7 months ago

MHz000 commented 7 months ago

Hello Jacob When I contact the brightsky server with the attached minimalistic ESP32 program I always get this error message. [E][WiFiGeneric.cpp:739] hostByName(): DNS Failed for https://api.brightsky.dev/current_weather?lat=52&lon=7.6 [E][WiFiClientSecure.cpp:133] connect(): start_ssl_client: -1 Have other brightsky users had similar experiences? Has anyone reported a successful connection between ESP32 and the server? It would be great if he/she shared his Arduino C++ code. Why do I bother you again? A connection to another server, e.g. to "www.howsmyssl.com" is established without any problems. The only difference I can see is in the access protocol. I'm sorry if I bother you with things that are outside of your responsibility. Thanks for the great project

jdemaeyer commented 7 months ago

Hi @MHz000,

sorry for the delay. There unfortunately is no attached ESP32 code, could you add that?

A possible issue here is that api.brightsky.dev has both an A and an AAAA record (i.e., it is available via IPv4 and IPv6), while www.howsmyssl.com has only an A record (it's only available via IPv4). Is there a way you could completely disable IPv6 on your ESP32, or otherwise change some settings so the DNS client queries the A record only?

MHz000 commented 7 months ago

Hello Jacob, delay... no problem at all. I'm grateful that you're even taking on my problem. I have to admit that I am completely unfamiliar with the Internet and WLAN protocols. I'm following examples I find online. I think I'm not alone in this. I appreciate it all the more and am grateful to you for your commitment. You'll see a series of URLs at the beginning of the minimalist code. Please don't feel obligated to waste your time. I will look for a solution that prevents IPv6 addresses from initiating a connection. Let's see if Google continues to be my friend. have a good time

/ https://www.brightsky.dev/ https://api.brightsky.dev/weather?lat=52&lon=7.6&date=2020-04-21 https://api.brightsky.dev/current_weather?lat=52&lon=7.6 // less data https://forum.arduino.cc/t/esp32-curl-with-wificlientsecure-h-for-api/1089308 https://RandomNerdTutorials.com/esp8266-nodemcu-https-requests/ // randomNerd https://microcontrollerslab.com/esp32-https-requests/ // microcontrollerslab https://github.com/espressif/arduino-esp32/issues/2778 <<< error discussion /

include

include

include

const char ssid = "worldgate";
const char
password = "balt1m0r3";

//const char host = "https://api.ocr.space/Parse/Image"; //const char host = "https://api.brightsky.dev/"; //const char host = "https://api.brightsky.dev/weather?lat=52&lon=7.6&date=2020-04-21"; const char host = "https://api.brightsky.dev/current_weather?lat=52&lon=7.6"; // https://api. //const char* host = "www.howsmyssl.com"; //https://randomnerdtutorials.com/esp32-https-requests/

int nowifi;

void setup() {
Serial.begin(115200); Serial.printf("\n\nCompiled from: %s at: %s %s", FILE, DATE, TIME); Serial.println("\nESP32_brightsky");

WiFi.mode(WIFI_STA); WiFi.begin(ssid, password);

Serial.println("connectet to WiFi"); while (WiFi.status() != WL_CONNECTED) {
delay(1000); nowifi++; Serial.print(nowifi); if(nowifi > 4) { ESP.restart(); } } Serial.println(""); Serial.println(WiFi.localIP()); Serial.println(WiFi.RSSI());
}

void loop() { Serial.println("Connecting to " + String(host)); WiFiClientSecure client; client.setInsecure(); / for(int i=0; i<3; i++){ if (client.connect(host, 443)) break; Serial.println(i); //ESP.restart(); delay(1000); } /

if (client.connect(host, 443)) { Serial.println("Successful connection!"); while(true){yield(); delay(100);};
/ String Data = "apikey: helloworld"; client.println("POST " + url + " HTTP/1.1"); client.println("Host: " + String(host)); client.println("Content-Length: " + String(Data.length()+photo.length())); client.println("Content-Type: application/image/jpg"); client.println(); client.print(Data); / } else {
Serial.println("\nConnection to " + String(host) + " failed"); while(true){yield(); delay(100);}; } client.stop(); delay(10000); } <\code>

MHz000 commented 7 months ago

Jakob pls have a look at https://community.platformio.org/t/difference-between-ipv4-ipv6-no-server-connection-with-esp32/38150 enjoy the weekend

Am Fr., 26. Jan. 2024 um 13:08 Uhr schrieb Jakob de Maeyer < @.***>:

Hi @MHz000 https://github.com/MHz000,

sorry for the delay. There unfortunately is no attached ESP32 code, could you add that?

A possible issue here is that api.brightsky.dev has both an A and an AAAA record (i.e., it is available via IPv4 and IPv6), while www.howsmyssl.com has only an A record (it's only available via IPv4). Is there a way you could completely disable IPv6 on your ESP32, or otherwise change some settings so the DNS client queries the A record only?

— Reply to this email directly, view it on GitHub https://github.com/jdemaeyer/brightsky/issues/161#issuecomment-1911972046, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB42SGVXB2CF23REUPZ66LLYQOMDZAVCNFSM6AAAAABB6SSDX6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJRHE3TEMBUGY . You are receiving this because you were mentioned.Message ID: @.***>