Skip to content

Commit f858b28

Browse files
committed
audio: rework HTTP timeout behaviour
Something between ESP-IDF v5.1.1 and 5.3.3 changed that causes the 10s timeout we set in the HTTP_STREAM_POST_REQUEST callback to be ignored when using HTTPS. Due to this, people with slower WIS cannot use Willow 0.4 anymore. Set the timeout to 10s in HTTP_STREAM_PRE_REQUEST to not use the ESP-ADF http_stream hardcoded default of 30s. If WIS is not running, or the user configured a wrong IP or port, the transport layer detects the problem early anyway.
1 parent ae4b51a commit f858b28

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

main/audio.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
#define DEFAULT_WIS_TTS_URL "https://infer.tovera.io/api/tts"
6060
#define DEFAULT_WIS_URL "https://infer.tovera.io/api/willow"
6161

62-
#define HTTP_STREAM_TIMEOUT_MS 2 * 1000
63-
#define HTTP_STREAM_TIMEOUT_MS_POST_REQUEST 10 * 1000
62+
#define HTTP_STREAM_TIMEOUT_MS 10 * 1000
6463

6564
#define MULTINET_TWDT 30
6665
#define STR_WAKE_LEN 25
@@ -225,9 +224,6 @@ static esp_err_t hdl_ev_hs_esp_audio(http_stream_event_msg_t *msg)
225224
esp_http_client_set_authtype(http, HTTP_AUTH_TYPE_BASIC);
226225
esp_http_client_set_timeout_ms(http, HTTP_STREAM_TIMEOUT_MS);
227226
break;
228-
case HTTP_STREAM_POST_REQUEST:
229-
esp_http_client_set_timeout_ms(http, HTTP_STREAM_TIMEOUT_MS_POST_REQUEST);
230-
break;
231227
default:
232228
break;
233229
}
@@ -572,7 +568,6 @@ static esp_err_t hdl_ev_hs_to_api(http_stream_event_msg_t *msg)
572568

573569
case HTTP_STREAM_POST_REQUEST:
574570
ESP_LOGI(TAG, "WIS HTTP client HTTP_STREAM_POST_REQUEST, write end chunked marker");
575-
esp_http_client_set_timeout_ms(http, HTTP_STREAM_TIMEOUT_MS_POST_REQUEST);
576571
if (esp_http_client_write(http, "0\r\n\r\n", 5) <= 0) {
577572
return ESP_FAIL;
578573
}
@@ -589,7 +584,6 @@ static esp_err_t hdl_ev_hs_to_api(http_stream_event_msg_t *msg)
589584
if (http_status != 200) {
590585
// when ESP HTTP Client terminates connection due to timeout we get -1
591586
if (http_status == -1) {
592-
ESP_LOGE(TAG, "WIS response took longer than %dms, connection aborted", HTTP_STREAM_TIMEOUT_MS);
593587
ui_pr_err("WIS timeout", "Check server performance");
594588
} else if (http_status == 401) {
595589
ESP_LOGE(TAG, "WIS returned Unauthorized Access (HTTP 401)");

0 commit comments

Comments
 (0)