HTTP Client Request Failed to Send with Errors

xpress_embedo
Posts: 12
Joined: Fri Jul 07, 2023 6:26 pm

HTTP Client Request Failed to Send with Errors

Postby xpress_embedo » Sun Jul 09, 2023 11:39 am

Hello Everyone,
I am new to ESP32 and ESP-IDF framework and wanted to get some data from the OpenWeatherMap website using HTTP Requests.
It works fine also but after some time, I am getting errors, and unable to fetch the data, the errors are as follows.

Code: Select all

E (69373) esp-sha: Failed to allocate buf memory
E (69833) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x7780
E (69833) esp-tls: Failed to open new connection
E (69833) transport_base: Failed to open a new connection
E (69843) HTTP_CLIENT: Connection failed, sock < 0
From the main_app function/task, I am calling another function every 10 seconds to send HTTP Client Request, like this.

Code: Select all

void openweathermap_init(void)
{
  // Initialize the City Names
  strcpy(city_weather[0].city_name, "delhi");
  strcpy(city_weather[1].city_name, "shimla");
  strcpy(city_weather[2].city_name, "jaipur");
  strcpy(city_weather[3].city_name, "leh");
}

void openweathermap_mng(void)
{
  if( request_in_process == false )
  {
    request_in_process = true;
    openweathermap_send_request();
  }
}
// Private Function Definitions
static void openweathermap_send_request(void)
{
  char openweathermap_url[200];
  snprintf( openweathermap_url, sizeof(openweathermap_url), \
            "%s%s%s", CLIENT_REQ_PRE, city_weather[city_weather_index].city_name, CLIENT_REQ_POST);

  esp_http_client_config_t config =
  {
    .url = openweathermap_url,
    .method = HTTP_METHOD_GET,
    .event_handler = openweathermap_event_handler,
  };

  // ESP_LOGI(TAG, "URL:%s", openweathermap_url);
  ESP_LOGI(TAG, "Free Heap: %lu", esp_get_free_heap_size() );

  esp_http_client_handle_t client = esp_http_client_init(&config);
  esp_http_client_set_header(client, CLIENT_KEY, CLIENT_VALUE);
  esp_err_t err = esp_http_client_perform(client);
  if( err == ESP_OK )
  {
    int status = esp_http_client_get_status_code(client);
    if(status == 200)
    {
      ESP_LOGI(TAG, "Message Sent Successfully");
    }
    else
    {
      ESP_LOGI(TAG, "Message Sent Failed");
    }
  }
  else
  {
    ESP_LOGI(TAG, "Message Sent Failed");
  }
  esp_http_client_cleanup(client);
}

static esp_err_t openweathermap_event_handler(esp_http_client_event_t *event)
{
  switch(event->event_id)
  {
    case HTTP_EVENT_ON_DATA:
      // Copy the Data to response_data buffer
      memcpy(response_data+response_data_idx, event->data, event->data_len);
      // Update the Length
      response_data_idx += event->data_len;
      break;
    case HTTP_EVENT_ON_FINISH:
      // Decode/Parse the weather data from the response data
      openweathermap_get_weather(response_data, &city_weather[city_weather_index]);
      // reset the response buffer and also the length to initial state
      openweathermap_reset_buffer();
      ESP_LOGI( TAG, "City=%s, Temp=%d, Pressure=%d, Humidity=%d", \
                city_weather[city_weather_index].city_name,   \
                city_weather[city_weather_index].temperature, \
                city_weather[city_weather_index].pressure,    \
                city_weather[city_weather_index].humidity);
      city_weather_index++;
      // Reset back to Initial Position
      if( city_weather_index >= NUM_OF_CITIES )
      {
        city_weather_index = 0;
      }
      // Free the system for next requests
      request_in_process = false;
      break;
    case HTTP_EVENT_ERROR:
      // In case of Error, exit
      openweathermap_reset_buffer();
      // Free the system for next requests
      request_in_process = false;
      break;
    default:
      break;
  }
  return ESP_OK;
}
For some minutes everything works fine, but after this, I started getting errors, the complete logs are as below.

Code: Select all

I (28033) OpenWeatherMap: Free Heap: 47024
I (29893) OpenWeatherMap: City=shimla, Temp=15, Pressure=1005, Humidity=97
I (29893) OpenWeatherMap: Message Sent Successfully
I (38103) OpenWeatherMap: Free Heap: 46812
I (39623) OpenWeatherMap: City=jaipur, Temp=31, Pressure=1002, Humidity=74
I (39623) OpenWeatherMap: Message Sent Successfully
I (48193) OpenWeatherMap: Free Heap: 46600
I (49923) OpenWeatherMap: City=leh, Temp=9, Pressure=1015, Humidity=95
I (49923) OpenWeatherMap: Message Sent Successfully
I (58233) OpenWeatherMap: Free Heap: 46388
I (60103) OpenWeatherMap: City=delhi, Temp=27, Pressure=1002, Humidity=94
I (60103) OpenWeatherMap: Message Sent Successfully
I (68243) OpenWeatherMap: Free Heap: 46176
E (69373) esp-sha: Failed to allocate buf memory
E (69833) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x7780
E (69833) esp-tls: Failed to open new connection
E (69833) transport_base: Failed to open a new connection
E (69843) HTTP_CLIENT: Connection failed, sock < 0
I (69843) OpenWeatherMap: Message Sent Failed
I (78303) OpenWeatherMap: Free Heap: 46176
I (79873) OpenWeatherMap: City=shimla, Temp=15, Pressure=1005, Humidity=97
I (79873) OpenWeatherMap: Message Sent Successfully
I (88363) OpenWeatherMap: Free Heap: 45964
I (90053) OpenWeatherMap: City=jaipur, Temp=31, Pressure=1002, Humidity=74
I (90053) OpenWeatherMap: Message Sent Successfully
I (98363) OpenWeatherMap: Free Heap: 45752
I (100033) OpenWeatherMap: City=leh, Temp=9, Pressure=1015, Humidity=95
I (100033) OpenWeatherMap: Message Sent Successfully
I (108393) OpenWeatherMap: Free Heap: 45540
I (110313) OpenWeatherMap: City=delhi, Temp=27, Pressure=1002, Humidity=94
I (110313) OpenWeatherMap: Message Sent Successfully
I (118433) OpenWeatherMap: Free Heap: 45328
E (119533) esp-sha: Failed to allocate buf memory
E (119533) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x0001
E (119533) esp-tls: Failed to open new connection
E (119543) transport_base: Failed to open a new connection
E (119563) HTTP_CLIENT: Connection failed, sock < 0
I (119563) OpenWeatherMap: Message Sent Failed
I (128473) OpenWeatherMap: Free Heap: 45116
E (129983) esp-sha: Failed to allocate buf memory
E (129983) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x6E00
E (129983) esp-tls: Failed to open new connection
E (129983) transport_base: Failed to open a new connection
E (129993) HTTP_CLIENT: Connection failed, sock < 0
I (129993) OpenWeatherMap: Message Sent Failed
I (138563) OpenWeatherMap: Free Heap: 44904
E (139523) esp-sha: Failed to allocate buf memory
W (139573) wifi:m f null

W (144533) esp-tls: Failed to open new connection in specified timeout
E (144533) transport_base: Failed to open a new connection
E (144543) HTTP_CLIENT: Connection failed, sock < 0
I (144543) OpenWeatherMap: Message Sent Failed
I (148593) OpenWeatherMap: Free Heap: 45120
I (150463) OpenWeatherMap: City=shimla, Temp=15, Pressure=1005, Humidity=97
I (150463) OpenWeatherMap: Message Sent Successfully
I (158653) OpenWeatherMap: Free Heap: 45120
I (160453) OpenWeatherMap: City=jaipur, Temp=31, Pressure=1002, Humidity=74
I (160453) OpenWeatherMap: Message Sent Successfully
I (168733) OpenWeatherMap: Free Heap: 45116
I (170433) OpenWeatherMap: City=leh, Temp=9, Pressure=1015, Humidity=95
I (170433) OpenWeatherMap: Message Sent Successfully
I (178833) OpenWeatherMap: Free Heap: 45116
E (181103) esp-sha: Failed to allocate buf memory
E (181113) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x6E00
E (181113) esp-tls: Failed to open new connection
E (181123) transport_base: Failed to open a new connection
E (181133) HTTP_CLIENT: Connection failed, sock < 0
I (181133) OpenWeatherMap: Message Sent Failed
I (188873) OpenWeatherMap: Free Heap: 45116
E (189943) esp-sha: Failed to allocate buf memory
E (190393) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x7780
E (190393) esp-tls: Failed to open new connection
E (190393) transport_base: Failed to open a new connection
E (190403) HTTP_CLIENT: Connection failed, sock < 0
I (190403) OpenWeatherMap: Message Sent Failed
I (198953) OpenWeatherMap: Free Heap: 44904
E (199103) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (199103) esp-tls: create_ssl_handle failed
E (199103) esp-tls: Failed to open new connection
E (199103) transport_base: Failed to open a new connection
E (199113) HTTP_CLIENT: Connection failed, sock < 0
I (199123) OpenWeatherMap: Message Sent Failed
I (209043) OpenWeatherMap: Free Heap: 44904
E (209343) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (209343) esp-tls: create_ssl_handle failed
E (209343) esp-tls: Failed to open new connection
E (209353) transport_base: Failed to open a new connection
E (209353) HTTP_CLIENT: Connection failed, sock < 0
I (209363) OpenWeatherMap: Message Sent Failed
I (219093) OpenWeatherMap: Free Heap: 44904
E (219323) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (219323) esp-tls: create_ssl_handle failed
E (219323) esp-tls: Failed to open new connection
E (219333) transport_base: Failed to open a new connection
E (219343) HTTP_CLIENT: Connection failed, sock < 0
I (219343) OpenWeatherMap: Message Sent Failed
I (229133) OpenWeatherMap: Free Heap: 44904
E (229303) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (229313) esp-tls: create_ssl_handle failed
E (229313) esp-tls: Failed to open new connection
E (229313) transport_base: Failed to open a new connection
E (229323) HTTP_CLIENT: Connection failed, sock < 0
I (229323) OpenWeatherMap: Message Sent Failed
I (239143) OpenWeatherMap: Free Heap: 45116
E (239293) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (239293) esp-tls: create_ssl_handle failed
E (239293) esp-tls: Failed to open new connection
E (239303) transport_base: Failed to open a new connection
E (239313) HTTP_CLIENT: Connection failed, sock < 0
I (239313) OpenWeatherMap: Message Sent Failed
I (249233) OpenWeatherMap: Free Heap: 44904
E (249533) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (249533) esp-tls: create_ssl_handle failed
E (249533) esp-tls: Failed to open new connection
E (249543) transport_base: Failed to open a new connection
E (249553) HTTP_CLIENT: Connection failed, sock < 0
I (249553) OpenWeatherMap: Message Sent Failed
I (259263) OpenWeatherMap: Free Heap: 44904
E (259523) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (259523) esp-tls: create_ssl_handle failed
E (259523) esp-tls: Failed to open new connection
E (259523) transport_base: Failed to open a new connection
E (259533) HTTP_CLIENT: Connection failed, sock < 0
I (259543) OpenWeatherMap: Message Sent Failed
I (269363) OpenWeatherMap: Free Heap: 44692
E (269423) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (269423) esp-tls: create_ssl_handle failed
E (269423) esp-tls: Failed to open new connection
E (269423) transport_base: Failed to open a new connection
E (269433) HTTP_CLIENT: Connection failed, sock < 0
I (269433) OpenWeatherMap: Message Sent Failed
I (279453) OpenWeatherMap: Free Heap: 44692
E (279743) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (279743) esp-tls: create_ssl_handle failed
E (279743) esp-tls: Failed to open new connection
E (279753) transport_base: Failed to open a new connection
E (279753) HTTP_CLIENT: Connection failed, sock < 0
I (279763) OpenWeatherMap: Message Sent Failed
I (289503) OpenWeatherMap: Free Heap: 44692
E (289553) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (289563) esp-tls: create_ssl_handle failed
E (289563) esp-tls: Failed to open new connection
E (289563) transport_base: Failed to open a new connection
E (289573) HTTP_CLIENT: Connection failed, sock < 0
I (289573) OpenWeatherMap: Message Sent Failed
I (299573) OpenWeatherMap: Free Heap: 44692
E (299713) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (299713) esp-tls: create_ssl_handle failed
E (299713) esp-tls: Failed to open new connection
E (299713) transport_base: Failed to open a new connection
E (299723) HTTP_CLIENT: Connection failed, sock < 0
I (299723) OpenWeatherMap: Message Sent Failed
I (309633) OpenWeatherMap: Free Heap: 44692
E (309953) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (309953) esp-tls: create_ssl_handle failed
E (309953) esp-tls: Failed to open new connection
E (309953) transport_base: Failed to open a new connection
E (309963) HTTP_CLIENT: Connection failed, sock < 0
I (309973) OpenWeatherMap: Message Sent Failed
I (319683) OpenWeatherMap: Free Heap: 44904
E (319933) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (319933) esp-tls: create_ssl_handle failed
E (319933) esp-tls: Failed to open new connection
E (319943) transport_base: Failed to open a new connection
E (319953) HTTP_CLIENT: Connection failed, sock < 0
I (319953) OpenWeatherMap: Message Sent Failed
I (329743) OpenWeatherMap: Free Heap: 44904
E (330183) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (330183) esp-tls: create_ssl_handle failed
E (330183) esp-tls: Failed to open new connection
E (330193) transport_base: Failed to open a new connection
E (330203) HTTP_CLIENT: Connection failed, sock < 0
I (330203) OpenWeatherMap: Message Sent Failed
I (339823) OpenWeatherMap: Free Heap: 44904
E (340163) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (340163) esp-tls: create_ssl_handle failed
E (340163) esp-tls: Failed to open new connection
E (340163) transport_base: Failed to open a new connection
E (340173) HTTP_CLIENT: Connection failed, sock < 0
I (340183) OpenWeatherMap: Message Sent Failed
I (349883) OpenWeatherMap: Free Heap: 44904
E (350143) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (350143) esp-tls: create_ssl_handle failed
E (350143) esp-tls: Failed to open new connection
E (350143) transport_base: Failed to open a new connection
E (350153) HTTP_CLIENT: Connection failed, sock < 0
I (350163) OpenWeatherMap: Message Sent Failed
I (359963) OpenWeatherMap: Free Heap: 44904
E (360383) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (360383) esp-tls: create_ssl_handle failed
E (360383) esp-tls: Failed to open new connection
E (360383) transport_base: Failed to open a new connection
E (360393) HTTP_CLIENT: Connection failed, sock < 0
I (360403) OpenWeatherMap: Message Sent Failed
I (370003) OpenWeatherMap: Free Heap: 44904
E (370113) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (370113) esp-tls: create_ssl_handle failed
E (370113) esp-tls: Failed to open new connection
E (370113) transport_base: Failed to open a new connection
E (370133) HTTP_CLIENT: Connection failed, sock < 0
I (370133) OpenWeatherMap: Message Sent Failed
I (380133) OpenWeatherMap: Free Heap: 44904
E (380353) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (380353) esp-tls: create_ssl_handle failed
E (380353) esp-tls: Failed to open new connection
E (380353) transport_base: Failed to open a new connection
E (380363) HTTP_CLIENT: Connection failed, sock < 0
I (380363) OpenWeatherMap: Message Sent Failed
I (390223) OpenWeatherMap: Free Heap: 44904
E (390593) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (390593) esp-tls: create_ssl_handle failed
E (390593) esp-tls: Failed to open new connection
E (390603) transport_base: Failed to open a new connection
E (390613) HTTP_CLIENT: Connection failed, sock < 0
I (390613) OpenWeatherMap: Message Sent Failed
I (400243) OpenWeatherMap: Free Heap: 44892
E (400833) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (400833) esp-tls: create_ssl_handle failed
E (400833) esp-tls: Failed to open new connection
E (400833) transport_base: Failed to open a new connection
E (400843) HTTP_CLIENT: Connection failed, sock < 0
I (400843) OpenWeatherMap: Message Sent Failed
I (410253) OpenWeatherMap: Free Heap: 44892
E (410553) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (410563) esp-tls: create_ssl_handle failed
E (410563) esp-tls: Failed to open new connection
E (410563) transport_base: Failed to open a new connection
E (410583) HTTP_CLIENT: Connection failed, sock < 0
I (410583) OpenWeatherMap: Message Sent Failed
I (420283) OpenWeatherMap: Free Heap: 44892
E (420793) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (420793) esp-tls: create_ssl_handle failed
E (420793) esp-tls: Failed to open new connection
E (420803) transport_base: Failed to open a new connection
E (420813) HTTP_CLIENT: Connection failed, sock < 0
I (420813) OpenWeatherMap: Message Sent Failed
I (430323) OpenWeatherMap: Free Heap: 44892
E (430533) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (430533) esp-tls: create_ssl_handle failed
E (430533) esp-tls: Failed to open new connection
E (430543) transport_base: Failed to open a new connection
E (430553) HTTP_CLIENT: Connection failed, sock < 0
I (430553) OpenWeatherMap: Message Sent Failed
I (440383) OpenWeatherMap: Free Heap: 44892
E (440533) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (440533) esp-tls: create_ssl_handle failed
E (440533) esp-tls: Failed to open new connection
E (440533) transport_base: Failed to open a new connection
E (440543) HTTP_CLIENT: Connection failed, sock < 0
I (440553) OpenWeatherMap: Message Sent Failed
I (450453) OpenWeatherMap: Free Heap: 44680
E (451003) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (451003) esp-tls: create_ssl_handle failed
E (451003) esp-tls: Failed to open new connection
E (451013) transport_base: Failed to open a new connection
E (451023) HTTP_CLIENT: Connection failed, sock < 0
I (451023) OpenWeatherMap: Message Sent Failed
I (460473) OpenWeatherMap: Free Heap: 44680
E (460733) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (460733) esp-tls: create_ssl_handle failed
E (460733) esp-tls: Failed to open new connection
E (460743) transport_base: Failed to open a new connection
E (460743) HTTP_CLIENT: Connection failed, sock < 0
I (460753) OpenWeatherMap: Message Sent Failed
I (470533) OpenWeatherMap: Free Heap: 44680
E (470973) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (470973) esp-tls: create_ssl_handle failed
E (470973) esp-tls: Failed to open new connection
E (470983) transport_base: Failed to open a new connection
E (470983) HTTP_CLIENT: Connection failed, sock < 0
I (470993) OpenWeatherMap: Message Sent Failed
I (480603) OpenWeatherMap: Free Heap: 44680
E (480703) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (480703) esp-tls: create_ssl_handle failed
E (480703) esp-tls: Failed to open new connection
E (480703) transport_base: Failed to open a new connection
E (480713) HTTP_CLIENT: Connection failed, sock < 0
I (480723) OpenWeatherMap: Message Sent Failed
I (490643) OpenWeatherMap: Free Heap: 44884
I (492993) OpenWeatherMap: City=delhi, Temp=27, Pressure=1002, Humidity=94
I (492993) OpenWeatherMap: Message Sent Successfully
I (500643) OpenWeatherMap: Free Heap: 44884
I (503233) OpenWeatherMap: City=shimla, Temp=15, Pressure=1005, Humidity=97
I (503233) OpenWeatherMap: Message Sent Successfully
I (510703) OpenWeatherMap: Free Heap: 44896
E (511983) esp-sha: Failed to allocate buf memory
E (511993) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x0001
E (511993) esp-tls: Failed to open new connection
E (511993) transport_base: Failed to open a new connection
E (512003) HTTP_CLIENT: Connection failed, sock < 0
I (512003) OpenWeatherMap: Message Sent Failed
I (520733) OpenWeatherMap: Free Heap: 44684
E (521153) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (521153) esp-tls: create_ssl_handle failed
E (521153) esp-tls: Failed to open new connection
E (521153) transport_base: Failed to open a new connection
E (521163) HTTP_CLIENT: Connection failed, sock < 0
I (521163) OpenWeatherMap: Message Sent Failed
I (530783) OpenWeatherMap: Free Heap: 44896
E (530873) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (530873) esp-tls: create_ssl_handle failed
E (530883) esp-tls: Failed to open new connection
E (530883) transport_base: Failed to open a new connection
E (530903) HTTP_CLIENT: Connection failed, sock < 0
I (530903) OpenWeatherMap: Message Sent Failed
I (540813) OpenWeatherMap: Free Heap: 44684
E (541113) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (541113) esp-tls: create_ssl_handle failed
E (541113) esp-tls: Failed to open new connection
E (541113) transport_base: Failed to open a new connection
E (541123) HTTP_CLIENT: Connection failed, sock < 0
I (541123) OpenWeatherMap: Message Sent Failed
I (550913) OpenWeatherMap: Free Heap: 44896
E (551353) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (551353) esp-tls: create_ssl_handle failed
E (551353) esp-tls: Failed to open new connection
E (551363) transport_base: Failed to open a new connection
E (551373) HTTP_CLIENT: Connection failed, sock < 0
I (551373) OpenWeatherMap: Message Sent Failed
I (561013) OpenWeatherMap: Free Heap: 44896
E (561343) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (561343) esp-tls: create_ssl_handle failed
E (561343) esp-tls: Failed to open new connection
E (561353) transport_base: Failed to open a new connection
E (561363) HTTP_CLIENT: Connection failed, sock < 0
I (561363) OpenWeatherMap: Message Sent Failed
I (571073) OpenWeatherMap: Free Heap: 44684
E (571333) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (571333) esp-tls: create_ssl_handle failed
E (571333) esp-tls: Failed to open new connection
E (571343) transport_base: Failed to open a new connection
E (571353) HTTP_CLIENT: Connection failed, sock < 0
I (571353) OpenWeatherMap: Message Sent Failed
I (581163) OpenWeatherMap: Free Heap: 44896
E (581313) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (581313) esp-tls: create_ssl_handle failed
E (581313) esp-tls: Failed to open new connection
E (581323) transport_base: Failed to open a new connection
E (581323) HTTP_CLIENT: Connection failed, sock < 0
I (581333) OpenWeatherMap: Message Sent Failed
I (591233) OpenWeatherMap: Free Heap: 44896
E (591553) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (591553) esp-tls: create_ssl_handle failed
E (591553) esp-tls: Failed to open new connection
E (591563) transport_base: Failed to open a new connection
E (591563) HTTP_CLIENT: Connection failed, sock < 0
I (591573) OpenWeatherMap: Message Sent Failed
I (601303) OpenWeatherMap: Free Heap: 44904
E (601533) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
E (601533) esp-tls: create_ssl_handle failed
E (601533) esp-tls: Failed to open new connection
E (601543) transport_base: Failed to open a new connection
E (601553) HTTP_CLIENT: Connection failed, sock < 0
I (601553) OpenWeatherMap: Message Sent Failed
I (611373) OpenWeatherMap: Free Heap: 44700
E (611773) esp-tls-mbedtls: mbedtls_ssl_setup returned -0x7F00
Can anyone please suggest what I am doing wrong?

Update, I kept the program running continuously, and what I found that it is crashing also, and following are the logs.

Code: Select all

I (562869) OpenWeatherMap: Message Sent Successfully
I (571219) OpenWeatherMap: Free Heap: 45236
W (577059) esp-tls: Failed to open new connection in specified timeout
E (577059) transport_base: Failed to open a new connection
E (577059) HTTP_CLIENT: Connection failed, sock < 0
I (577059) OpenWeatherMap: Message Sent Failed
I (581229) OpenWeatherMap: Free Heap: 45448
I (582839) OpenWeatherMap: City=leh, Temp=9, Pressure=1015, Humidity=94
I (582839) OpenWeatherMap: Message Sent Successfully
I (591329) OpenWeatherMap: Free Heap: 45448
E (592349) esp-sha: Failed to allocate buf memory
E (592349) esp-tls-mbedtls: mbedtls_ssl_handshake returned -0x0001
E (592349) esp-tls: Failed to open new connection
E (592349) transport_base: Failed to open a new connection
E (592359) HTTP_CLIENT: Connection failed, sock < 0
I (592369) OpenWeatherMap: Message Sent Failed
I (601379) OpenWeatherMap: Free Heap: 45224
I (603109) OpenWeatherMap: City=delhi, Temp=26, Pressure=1001, Humidity=100
I (603109) OpenWeatherMap: Message Sent Successfully
I (611449) OpenWeatherMap: Free Heap: 45012
E (611789) esp-sha: Failed to allocate buf memory

abort() was called at PC 0x400eb1cf on core 0
0x400eb1cf: sha_hal_read_digest at C:/Espressif/frameworks/esp-idf-v5.0.2/components/hal/sha_hal.c:137



Backtrace: 0x40025bc6:0x3ffd49c0 0x4002db75:0x3ffd49e0 0x40034e7a:0x3ffd4a00 0x400eb1cf:0x3ffd4a70 0x400cab01:0x3ffd4a90 0x400c842c:0x3ffd4ab0 0x400c5f4a:0x3ffd4ad0 0x40115bda:0x3ffd4af0 0x40116ba0:0x3ffd4b20 0x4011718a:0x3ffd4bb0 0x40114f3e:0x3ffd4bd0 0x40114fa9:0x3ffd4bf0 0x4012495a:0x3ffd4c10 0x401240ed:0x3ffd4c30 0x4012430a:0x3ffd4c50 0x40124417:0x3ffd4c90 0x40112cf3:0x3ffd4cc0 0x4013ef11:0x3ffd4cf0 0x400c251d:0x3ffd4d10 0x400c2883:0x3ffd4d30 0x400891ed:0x3ffd4d50 0x400893af:0x3ffd4ec0 0x40089141:0x3ffd4ee0 0x4014166d:0x3ffd4f00 0x400304e1:0x3ffd4f30
0x40025bc6: panic_abort at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp_system/panic.c:423

0x4002db75: esp_system_abort at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp_system/esp_system.c:153

0x40034e7a: abort at C:/Espressif/frameworks/esp-idf-v5.0.2/components/newlib/abort.c:38

0x400eb1cf: sha_hal_read_digest at C:/Espressif/frameworks/esp-idf-v5.0.2/components/hal/sha_hal.c:137

0x400cab01: esp_sha_read_digest_state at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/port/sha/dma/sha.c:88

0x400c842c: mbedtls_sha512_update at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/port/sha/dma/esp_sha512.c:202

0x400c5f4a: mbedtls_md_update at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/mbedtls/library/md.c:499

0x40115bda: mbedtls_ssl_get_key_exchange_md_tls1_2 at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/mbedtls/library/ssl_tls.c:8652

0x40116ba0: ssl_parse_server_key_exchange at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/mbedtls/library/ssl_tls12_client.c:2486

0x4011718a: mbedtls_ssl_handshake_client_step at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/mbedtls/library/ssl_tls12_client.c:3698

0x40114f3e: mbedtls_ssl_handshake_step at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/mbedtls/library/ssl_tls.c:3730

0x40114fa9: mbedtls_ssl_handshake at C:/Espressif/frameworks/esp-idf-v5.0.2/components/mbedtls/mbedtls/library/ssl_tls.c:3795

0x4012495a: esp_mbedtls_handshake at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp-tls/esp_tls_mbedtls.c:192

0x401240ed: esp_tls_handshake at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp-tls/esp_tls.c:85

0x4012430a: esp_tls_low_level_conn at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp-tls/esp_tls.c:443 (discriminator 15)

0x40124417: esp_tls_conn_new_sync at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp-tls/esp_tls.c:470

0x40112cf3: ssl_connect at C:/Espressif/frameworks/esp-idf-v5.0.2/components/tcp_transport/transport_ssl.c:109

0x4013ef11: esp_transport_connect at C:/Espressif/frameworks/esp-idf-v5.0.2/components/tcp_transport/transport.c:123

0x400c251d: esp_http_client_connect at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp_http_client/esp_http_client.c:1289

0x400c2883: esp_http_client_perform at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp_http_client/esp_http_client.c:1136

0x400891ed: openweathermap_send_request at D:/Projects/Embedded/ESP32/ESP-IDF/OpenWeatherMap/main/openweathermap.c:143

0x400893af: openweathermap_mng at D:/Projects/Embedded/ESP32/ESP-IDF/OpenWeatherMap/main/openweathermap.c:61

0x40089141: app_main at D:/Projects/Embedded/ESP32/ESP-IDF/OpenWeatherMap/main/main.c:72

0x4014166d: main_task at C:/Espressif/frameworks/esp-idf-v5.0.2/components/freertos/FreeRTOS-Kernel/portable/port_common.c:131 (discriminator 2)

0x400304e1: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.0.2/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:154





ELF file SHA256: bfc9fd6483ba7756

Rebooting...
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4002564d
0x4002564d: esp_restart_noos_dig at C:/Espressif/frameworks/esp-idf-v5.0.2/components/esp_system/esp_system.c:64 (discriminator 1)

SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6108,len:0x1760
load:0x4004c000,len:0xabc
load:0x40050000,len:0x31b4
entry 0x4004c1c0
I (24) boot: ESP-IDF v5.0.2 2nd stage bootloader
I (24) boot: compile time 10:32:46
I (24) boot: chip revision: v0.0
I (26) boot.esp32s2: SPI Speed      : 80MHz
I (31) boot.esp32s2: SPI Mode       : DIO
I (36) boot.esp32s2: SPI Flash Size : 4MB
I (41) boot: Enabling RNG early entropy source...
I (46) boot: Partition Table:
I (50) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (64) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (72) boot:  2 factory          factory app      00 00 00010000 00300000
I (83) esp_image: segment 0: paddr=00010020 vaddr=3f000020 size=111410h (1119248) map
I (315) esp_image: segment 1: paddr=00121438 vaddr=3ffca110 size=03384h ( 13188) load
I (318) esp_image: segment 2: paddr=001247c4 vaddr=40024000 size=0b854h ( 47188) load
I (333) esp_image: segment 3: paddr=00130020 vaddr=40080020 size=c1e50h (794192) map
I (491) esp_image: segment 4: paddr=001f1e78 vaddr=4002f854 size=0a8b8h ( 43192) load
I (513) boot: Loaded app from partition at offset 0x10000
I (513) boot: Disabling RNG early entropy source...
I (525) cache: Instruction cache        : size 8KB, 4Ways, cache line size 32Byte
I (525) cache: Data cache               : size 8KB, 4Ways, cache line size 32Byte
I (531) esp_psram: Found 2MB PSRAM device
I (535) esp_psram: Speed: 80MHz
I (539) cpu_start: Pro cpu up.
I (762) esp_psram: SPI SRAM memory test OK
I (769) cpu_start: Pro cpu start user code
I (769) cpu_start: cpu freq: 160000000 Hz
I (769) cpu_start: Application information:
I (772) cpu_start: Project name:     OpenWeatherMap
I (778) cpu_start: App version:      90e4bfd-dirty
I (783) cpu_start: Compile time:     Jul  9 2023 14:08:05
I (789) cpu_start: ELF file SHA256:  bfc9fd6483ba7756...
I (795) cpu_start: ESP-IDF:          v5.0.2
I (800) cpu_start: Min chip rev:     v0.0
I (805) cpu_start: Max chip rev:     v1.99
I (810) cpu_start: Chip rev:         v0.0
I (815) heap_init: Initializing. RAM available for dynamic allocation:
I (822) heap_init: At 3FFD2160 len 00029EA0 (167 KiB): DRAM
I (828) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (834) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
I (841) spi_flash: detected chip: generic
I (845) spi_flash: flash io: dio
I (879) cpu_start: Starting scheduler on PRO CPU.
I (909) wifi:wifi driver task: 3ffda790, prio:23, stack:6656, core=0
I (909) system_api: Base MAC address is not set
I (909) system_api: read default base MAC address from EFUSE
I (919) wifi:wifi firmware version: 57982fe
I (919) wifi:wifi certification version: v7.0
I (919) wifi:config NVS flash: enabled
I (919) wifi:config nano formating: disabled
I (929) wifi:Init data frame dynamic rx buffer num: 32
I (929) wifi:Init management frame dynamic rx buffer num: 32
I (939) wifi:Init management short buffer num: 32
I (939) wifi:Init dynamic tx buffer num: 32
I (949) wifi:Init tx cache buffer num: 32
I (949) wifi:Init static rx buffer size: 1600
I (949) wifi:Init static rx buffer num: 10
I (959) wifi:Init dynamic rx buffer num: 32
I (959) wifi_init: rx ba win: 6
I (969) wifi_init: tcpip mbox: 32
I (969) wifi_init: udp mbox: 6
I (969) wifi_init: tcp mbox: 6
I (979) wifi_init: tcp tx win: 5744
I (979) wifi_init: tcp rx win: 5744
I (989) wifi_init: tcp mss: 1440
I (989) wifi_init: WiFi IRAM OP enabled
I (989) wifi_init: WiFi RX IRAM OP enabled
I (1059) phy_init: phy_version 2300,d67cf06,Feb 10 2022,10:03:07
I (1099) wifi:mode : sta (7c:df:a1:0e:38:74)
I (1099) wifi:enable tsf
I (1099) WIFI: Connecting to AP...
I (1099) WIFI: STA Initialization Complete
I (1109) wifi:new:<11,2>, old:<1,0>, ap:<255,255>, sta:<11,2>, prof:1
I (2159) wifi:state: init -> auth (b0)
I (2169) wifi:state: auth -> assoc (0)
E (2179) wifi:Association refused temporarily, comeback time 1024 mSec
I (3199) wifi:state: assoc -> assoc (0)
I (4199) wifi:state: assoc -> init (200)
I (4199) wifi:new:<11,0>, old:<11,2>, ap:<255,255>, sta:<11,2>, prof:1
I (4199) WIFI: Reconnecting to AP...
I (6619) WIFI: Reconnecting to AP...
I (6629) wifi:new:<11,2>, old:<11,0>, ap:<255,255>, sta:<11,2>, prof:1
I (6629) wifi:state: init -> auth (b0)
I (6629) wifi:state: auth -> assoc (0)
I (6639) wifi:state: assoc -> run (10)
I (6679) wifi:connected with gigacube-D733, aid = 1, channel 11, 40D, bssid = c8:ea:f8:7c:d7:33
I (6679) wifi:security: WPA2-PSK, phy: bgn, rssi: -69
I (6689) wifi:pm start, type: 1

I (6819) wifi:AP's beacon interval = 256000 us, DTIM period = 1
I (7689) esp_netif_handlers: sta ip: 192.168.0.4, mask: 255.255.255.0, gw: 192.168.0.1
I (7689) WIFI: STA IP: 192.168.0.4
I (7689) WIFI: Connected To Access Point
I (7689) LVGL: Starting LVGL task
I (7699) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (7709) gpio: GPIO[16]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I anyone has some suggestions, please let me know.
Thanks, and Regards

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 229 guests