Closed pablozg closed 1 year ago
This is enough
platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.04.02/platform-espressif32.zip
Can you provide a small test sketch where you encounter the problem?
Closing since no feedback
I'm sorry, last week I was very busy, here you have a test code:
#include "WiFi.h"
#include <sys/param.h>
#include "esp_http_client.h"
#include "esp_tls.h"
unsigned long boot_time;
char ssid[] = "ssid"; // your network SSID (name)
char pass[] = "pass"; // your network password
#define MAX_HTTP_RECV_BUFFER 512
#define MAX_HTTP_OUTPUT_BUFFER 2048
static char local_response_buffer[MAX_HTTP_OUTPUT_BUFFER] = {0};
esp_err_t _http_event_handler(esp_http_client_event_t *evt)
{
switch(evt->event_id) {
case HTTP_EVENT_ERROR:
Serial.printf("HTTP_EVENT_ERROR\n");
break;
case HTTP_EVENT_ON_CONNECTED:
Serial.printf("HTTP_EVENT_ON_CONNECTED\n");
break;
case HTTP_EVENT_HEADER_SENT:
Serial.printf("HTTP_EVENT_HEADER_SENT\n");
break;
case HTTP_EVENT_ON_HEADER:
Serial.printf("HTTP_EVENT_ON_HEADER, key=%s, value=%s\n", evt->header_key, evt->header_value);
break;
case HTTP_EVENT_ON_DATA:
Serial.printf("HTTP_EVENT_ON_DATA, len=%d\n", evt->data_len);
break;
case HTTP_EVENT_ON_FINISH:
Serial.printf("HTTP_EVENT_ON_FINISH\n");
break;
case HTTP_EVENT_DISCONNECTED:
Serial.printf("HTTP_EVENT_DISCONNECTED\n");
break;
}
return ESP_OK;
}
static void http_auth_digest(void)
{
esp_http_client_config_t config = {
// .url = "http://user:passwd@httpbin.org/digest-auth/auth/user/passwd/MD5/never",
.url = "http://httpbin.org/digest-auth/auth/user/passwd/MD5/never",
.username = "user",
.password = "passwd",
.auth_type = HTTP_AUTH_TYPE_DIGEST,
.timeout_ms = 3000,
.event_handler = _http_event_handler,
.transport_type = HTTP_TRANSPORT_OVER_TCP,
.buffer_size = 1024,
.buffer_size_tx = 512,
};
esp_http_client_handle_t client = esp_http_client_init(&config);
Serial.printf("Opening non-secure connection\n");
esp_err_t err = esp_http_client_open(client, 0);
if (err == ESP_OK) {
Serial.printf("HTTP Digest Auth Status = %d, content_length = %" PRIu64 "\n",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
} else {
Serial.printf("Error perform http request %s\n", esp_err_to_name(err));
}
Serial.printf("Reading all headers\n");
esp_http_client_fetch_headers(client);
Serial.printf("Adding digest auth header\n");
esp_http_client_add_auth(client); // In this call do the kernel panic
Serial.printf("Closing connection\n");
esp_http_client_close(client);
Serial.printf("Performing request again\n");
esp_http_client_set_header(client, "Connection", "Keep-Alive");
esp_http_client_set_header(client, "Cache-Control", "max-age=0");
err = esp_http_client_open(client, 0);
if (err == ESP_OK) {
Serial.printf("HTTP Digest Auth Status = %d, content_length = %" PRIu64 "\n",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
size_t readLen = esp_http_client_read(client, local_response_buffer, 512); // 128
if (readLen >= 0) {
Serial.printf("Len: %d, Read data: %s\n", readLen, local_response_buffer);
} else { Serial.printf("Fail to read data\n"); }
} else {
Serial.printf("Error perform http request %s\n", esp_err_to_name(err));
}
Serial.printf("Cleaning up\n");
esp_http_client_cleanup(client);
}
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
WiFi.begin(ssid, pass);
delay(100);
// attempt to connect to Wifi network:
while (WiFi.status() != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
delay(1000);
}
Serial.print("You're connected to the network\n");
}
void loop()
{
http_auth_digest();
delay(2000);
}
Using the default config from espressif arduino builder and your lwip timeout branch, I was able to run my code without this issue.
Platformio config:
[env:heltec_wifi_kit_32] framework = arduino board = heltec_wifi_kit_32
; Basado en idf 4.4.4 platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.04.02/platform-espressif32.zip platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1322/framework-arduinoespressif32.zip
Probably because we use the ROM inbuilt nano lib. Not all features are supported for printf.
Could be serial.printf
is not supported. Thanks for the feedback.
Since we use only features which are supported in nano lib, we will keep.
nano lib is activated here https://github.com/Jason2866/esp32-arduino-lib-builder/blob/Arduino/configs/defconfig.esp32#L83
The problem isn't the printf (I put it for clarify), in my original code no Serial.printf or log_i or ESP_LOGI are used. The kernel panic happens when call the 'esp_http_client_add_auth(client);' function.
Interesting issue. After some Core panic reboots, it is working.
It is a timeout issue. When i change to .timeout_ms = 500,
it crashes seldom. Lowering more solves crashing.
The used Tasmota IDF lwip code (older) is different from release core 2.0.8. With newer lwip code we have issues when using wifi and ethernet together. It is good for us, maybe not for you.
Wit "400" get no crash and this output
Attempting to connect to WPA SSID: Jason_Home_WLAN
You're connected to the network
Opening non-secure connection
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = 0, content_length = lu
Reading all headers
Adding digest auth header
Closing connection
HTTP_EVENT_DISCONNECTED
Performing request again
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = -1, content_length = lu
Len: 0, Read data:
Cleaning up
HTTP_EVENT_DISCONNECTED
Opening non-secure connection
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = 0, content_length = lu
Reading all headers
Adding digest auth header
Closing connection
HTTP_EVENT_DISCONNECTED
Performing request again
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = -1, content_length = lu
Len: 0, Read data:
Cleaning up
HTTP_EVENT_DISCONNECTED
Opening non-secure connection
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = 0, content_length = lu
Reading all headers
Adding digest auth header
Closing connection
HTTP_EVENT_DISCONNECTED
Performing request again
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = -1, content_length = lu
Len: 0, Read data:
Cleaning up
HTTP_EVENT_DISCONNECTED
Opening non-secure connection
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = 0, content_length = lu
Reading all headers
Adding digest auth header
Closing connection
HTTP_EVENT_DISCONNECTED
Performing request again
HTTP_EVENT_ERROR
Error perform http request UNKNOWN ERROR
Cleaning up
HTTP_EVENT_DISCONNECTED
Opening non-secure connection
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = 0, content_length = lu
Reading all headers
Adding digest auth header
Closing connection
HTTP_EVENT_DISCONNECTED
Performing request again
HTTP_EVENT_ON_CONNECTED
HTTP_EVENT_HEADER_SENT
HTTP Digest Auth Status = -1, content_length = lu
Len: 0, Read data:
Cleaning up
HTTP_EVENT_DISCONNECTED
Opening non-secure connection
Yes, it's a Interesting issue, using your builder with the original values from espressif and the lwip-timeout branch works well, so by the moment I will use my custom build with lwip-timeout, seems to fix some the issues with the dhcp server connection.
thanks for you work.
Hi, Using your release in order to avoid the dhcp connect issue with some routers,
I get a collateral issue:
when return back to:
the issue is gone.
I tried to compile my own version, but the changes I made don't work.
Do you know what option must change on menuconfig to fix it?
thanks.