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

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

Closed
MHz000 opened this issue Jan 17, 2024 · 3 comments
Closed

Comments

@MHz000
Copy link

MHz000 commented Jan 17, 2024

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
Copy link
Owner

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
Copy link
Author

MHz000 commented Jan 26, 2024

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 <Arduino.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>

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 MHz000 closed this as completed Jan 26, 2024
@MHz000
Copy link
Author

MHz000 commented Jan 27, 2024 via email

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

2 participants