Skip to content

Commit

Permalink
Merge branch 'bugfix/esp_http_server_config' into 'master'
Browse files Browse the repository at this point in the history
esp_http_server: fix default control port for HTTPS configuration

Closes IDFGH-8719 and IDFGH-8663

See merge request espressif/esp-idf!21089
  • Loading branch information
mahavirj committed Nov 21, 2022
2 parents 1657db5 + 79216c6 commit 2c9eb26
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions components/esp_http_server/include/esp_http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
extern "C" {
#endif

#define ESP_HTTPD_DEF_CTRL_PORT (32768) /*!< HTTP Server control socket port*/

/*
note: esp_https_server.h includes a customized copy of this
initializer that should be kept in sync
Expand All @@ -28,7 +30,7 @@ initializer that should be kept in sync
.stack_size = 4096, \
.core_id = tskNO_AFFINITY, \
.server_port = 80, \
.ctrl_port = 32768, \
.ctrl_port = ESP_HTTPD_DEF_CTRL_PORT, \
.max_open_sockets = 7, \
.max_uri_handlers = 8, \
.max_resp_headers = 8, \
Expand Down Expand Up @@ -153,7 +155,7 @@ typedef struct httpd_config {
*/
uint16_t ctrl_port;

uint16_t max_open_sockets; /*!< Max number of sockets/clients connected at any time*/
uint16_t max_open_sockets; /*!< Max number of sockets/clients connected at any time (3 sockets are reserved for internal working of the HTTP server) */
uint16_t max_uri_handlers; /*!< Maximum allowed uri handlers */
uint16_t max_resp_headers; /*!< Maximum allowed additional headers in HTTP response */
uint16_t backlog_conn; /*!< Number of backlog connections */
Expand Down
2 changes: 1 addition & 1 deletion components/esp_http_server/src/httpd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ esp_err_t httpd_start(httpd_handle_t *handle, const httpd_config_t *config)
* So the total number of required sockets is max_open_sockets + 3
*/
if (CONFIG_LWIP_MAX_SOCKETS < config->max_open_sockets + 3) {
ESP_LOGE(TAG, "Configuration option max_open_sockets is too large (max allowed %d)\n\t"
ESP_LOGE(TAG, "Config option max_open_sockets is too large (max allowed %d, 3 sockets used by HTTP server internally)\n\t"
"Either decrease this or configure LWIP_MAX_SOCKETS to a larger value",
CONFIG_LWIP_MAX_SOCKETS - 3);
return ESP_ERR_INVALID_ARG;
Expand Down
2 changes: 1 addition & 1 deletion components/esp_https_server/include/esp_https_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ typedef struct httpd_ssl_config httpd_ssl_config_t;
.stack_size = 10240, \
.core_id = tskNO_AFFINITY, \
.server_port = 0, \
.ctrl_port = 32768, \
.ctrl_port = ESP_HTTPD_DEF_CTRL_PORT+1, \
.max_open_sockets = 4, \
.max_uri_handlers = 8, \
.max_resp_headers = 8, \
Expand Down

0 comments on commit 2c9eb26

Please sign in to comment.