From: David Cermak Date: Thu, 22 Aug 2019 19:01:08 +0000 (+0200) Subject: ws_client: fixed transport config option when server address configured as host,... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=adee25d90e100a169e959f94db23621f6ffab0e6;p=esp-idf ws_client: fixed transport config option when server address configured as host, port, transport rather then uri closes https://github.com/espressif/esp-idf/issues/3891 --- diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index cc77267d0a..a3226350ed 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -224,6 +224,9 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie client->lock = xSemaphoreCreateMutex(); ESP_WS_CLIENT_MEM_CHECK(TAG, client->lock, goto _websocket_init_fail); + client->config = calloc(1, sizeof(websocket_config_storage_t)); + ESP_WS_CLIENT_MEM_CHECK(TAG, client->config, goto _websocket_init_fail); + client->transport_list = esp_transport_list_init(); ESP_WS_CLIENT_MEM_CHECK(TAG, client->transport_list, goto _websocket_init_fail); @@ -259,14 +262,11 @@ esp_websocket_client_handle_t esp_websocket_client_init(const esp_websocket_clie esp_transport_set_default_port(wss, WEBSOCKET_SSL_DEFAULT_PORT); esp_transport_list_add(client->transport_list, wss, "wss"); - if (config->transport == WEBSOCKET_TRANSPORT_OVER_TCP) { + if (config->transport == WEBSOCKET_TRANSPORT_OVER_SSL) { asprintf(&client->config->scheme, "wss"); ESP_WS_CLIENT_MEM_CHECK(TAG, client->config->scheme, goto _websocket_init_fail); } - client->config = calloc(1, sizeof(websocket_config_storage_t)); - ESP_WS_CLIENT_MEM_CHECK(TAG, client->config, goto _websocket_init_fail); - if (config->uri) { if (esp_websocket_client_set_uri(client, config->uri) != ESP_OK) { ESP_LOGE(TAG, "Invalid uri");