From 99805d880f41857702b3bbb35bc0dfaf7dec3aec Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 2 Feb 2021 10:38:34 +0100 Subject: [PATCH] websockets: Set keepalive options after adding transport to the list To be in line with other code and mainly to support base/foundation transport used by both tcp and ssl transport layers --- components/esp_websocket_client/esp_websocket_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index 167a9d4b07..055a237722 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -329,8 +329,8 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie ESP_WS_CLIENT_MEM_CHECK(TAG, tcp, goto _websocket_init_fail); esp_transport_set_default_port(tcp, WEBSOCKET_TCP_DEFAULT_PORT); - esp_transport_tcp_set_keep_alive(tcp, &client->keep_alive_cfg); esp_transport_list_add(client->transport_list, tcp, "_tcp"); // need to save to transport list, for cleanup + esp_transport_tcp_set_keep_alive(tcp, &client->keep_alive_cfg); esp_transport_handle_t ws = esp_transport_ws_init(tcp); @@ -347,6 +347,7 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie ESP_WS_CLIENT_MEM_CHECK(TAG, ssl, goto _websocket_init_fail); esp_transport_set_default_port(ssl, WEBSOCKET_SSL_DEFAULT_PORT); + esp_transport_list_add(client->transport_list, ssl, "_ssl"); // need to save to transport list, for cleanup if (config->use_global_ca_store == true) { esp_transport_ssl_enable_global_ca_store(ssl); } else if (config->cert_pem) { @@ -374,7 +375,6 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie esp_transport_ssl_skip_common_name_check(ssl); } esp_transport_ssl_set_keep_alive(ssl, &client->keep_alive_cfg); - esp_transport_list_add(client->transport_list, ssl, "_ssl"); // need to save to transport list, for cleanup esp_transport_handle_t wss = esp_transport_ws_init(ssl); ESP_WS_CLIENT_MEM_CHECK(TAG, wss, goto _websocket_init_fail);