5

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
2
  • 1
    Did you find an answer? I'm having this issue now, and it's pretty much what you're describing.
    – mahboudz
    Commented Aug 16, 2023 at 19:52
  • 1
    They said it is pending from the development. It will be solved in ESP 3.0 version. Follow this roadmap for update : github.com/orgs/espressif/projects/3/views/14. There are other alternatives on there GitHub page but are quite complicated. You can dig into that, I didn't.
    – dharmikP
    Commented Sep 9, 2023 at 0:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.