I'm not able to get my esp to connect to a desired server, it always returns error "HTTP_CLIENT: Connection failed, sock < 0". By doing some research on the esp forums etc I found that people were having problems to make their DNS to work when running the ESP32 on either STA or AP mode.
Now I'm trying to connect to my server to make some REST requests but it always fails. So I commented the part of the code where I assigned a static IP to my AP (static IP only in AP mode) and then it started to work.
I tried to set the DNS by hand. Tried with most common ones like 8.8.8.8 and 1.1.1.1 but didn't work.
This is the part of the code where I assign it a static IP and a specific DNS server.
Code: Select all
my_ap = esp_netif_create_default_wifi_ap();
esp_netif_ip_info_t ip_info = {0};
esp_netif_dns_info_t dns_info = {0};
IP4_ADDR(&ip_info.ip, 192,168,1,1);
IP4_ADDR(&ip_info.gw, 192,168,1,1);
IP4_ADDR(&ip_info.netmask, 255,255,255,0);
IP_ADDR4(&dns_info.ip, 8, 8, 8, 8);
esp_netif_dhcps_stop(my_ap);
esp_netif_set_ip_info(my_ap, &ip_info);
esp_netif_set_dns_info(my_ap, ESP_NETIF_DNS_MAIN, &dns_info);
esp_netif_dhcps_start(my_ap);