I have a problem with WiFiClientSecure, it can't make a connection to HTTPS and HTTP servers (port 443 and 80). I know that I have to set the DNS server IP, however, since we have many nodes that connect to a router, dedicating a static IP for each one is not a good solution. All of them have the same code and the IP must be set dynamically by the router. The point is, I want to set the DNS server IP manually but there is not such a command for this purpose.
I've read about the Arduino WiFi shield and it has a command to set one or two DNS servers without setting static IP. I want to know is it possible to add this command to the library?!!
WiFi.setDNS(dns1); or WiFi.setDNS(dns1, dns2);
Example
#include <Arduino.h>
// Network Configurations
#define WLAN_SSID "YOUR_WIRELESS_SSID"
#define WLAN_PASSWORD "YOUR_PASSWORD"
// the IP address for the shield:
IPAddress dns1(8, 8, 8, 8); //Google dns
IPAddress dns2(8, 8, 4, 4); //Alternate dns
void setup() {
WiFi.mode(WIFI_STA);
WiFi.begin(WLAN_SSID, WLAN_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println();
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
// print your WiFi IP address:
WiFi.setDNS(dns1); //WiFi.setDNS(dns1, dns2);
Serial.print("Dns configured.");
}
void loop() {}
SetDNS method
Description
I have a problem with WiFiClientSecure, it can't make a connection to HTTPS and HTTP servers (port 443 and 80). I know that I have to set the DNS server IP, however, since we have many nodes that connect to a router, dedicating a static IP for each one is not a good solution. All of them have the same code and the IP must be set dynamically by the router. The point is, I want to set the DNS server IP manually but there is not such a command for this purpose. I've read about the Arduino WiFi shield and it has a command to set one or two DNS servers without setting static IP. I want to know is it possible to add this command to the library?!!
Example