I am using ESP-WROOM-32D in STA mode with Arduino IDE(2.0.5) ESP32 board(2.0.9). I am trying to do http post request with ESP32. Router that provides internet supports only IPv6.
Here I am getting http code -1. I have tried different network with IPv4 which works fine and returns 200.
So my question is do I need to enable something to make this work ? I have used WiFi.enableIpV6(); and got IPv6 IP also.
void setup() {
Serial.begin(115200);
delay(2000);
WiFi.onEvent(WiFiEvent);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(300);
Serial.println(".");
}
Serial.println("wifi connected");
delay(2000);
HTTPClient http;
http.begin("https://www.google.com/");
int httpCode = http.GET();
Serial.printf("HTTP code: %d\n", httpCode);
http.end();
}
void loop() {
}
void WiFiEvent(WiFiEvent_t event) {
switch (event) {
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
Serial.println("Enabling IPv6");
WiFi.enableIpV6();
break;
default:
break;
}
}
This is the debug message I got
[ 4][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[ 2053][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 2144][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 2 - STA_START
[ 2313][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
Enabling IPv6
.
[ 2620][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[ 2620][D][WiFiGeneric.cpp:1098] _eventCallback(): STA IP: 192.168.1.3, MASK: 255.255.255.0, GW: 192.168.1.1
.
wifi connected
[ 4035][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 8 - STA_GOT_IP6
[ 4774][D][HTTPClient.cpp:263] beginInternal(): unexpected protocol: https, expected http
[ 4775][D][HTTPClient.cpp:303] beginInternal(): protocol: https, host: www.google.com port: 443 url: /
[ 4781][D][HTTPClient.cpp:598] sendRequest(): request type: 'GET' redirCount: 0
[ 5035][D][WiFiGeneric.cpp:1035] _eventCallback(): Arduino Event: 8 - STA_GOT_IP6
[ 9829][I][ssl_client.cpp:112] start_ssl_client(): select returned due to timeout 5000 ms for fd 48
[ 9830][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -1
[ 9833][D][HTTPClient.cpp:1163] connect(): failed connect to www.google.com:443
[ 9840][W][HTTPClient.cpp:1483] returnError(): error(-1): connection refused
HTTP code: -1
[ 9858][D][HTTPClient.cpp:408] disconnect(): tcp is closed