Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After initializing websocket, the error httpd: httpd_server: error in select (9) will appear. (IDFGH-14242) #15038

Closed
3 tasks done
wolen666 opened this issue Dec 16, 2024 · 1 comment
Assignees
Labels
Status: Opened Issue is new

Comments

@wolen666
Copy link

wolen666 commented Dec 16, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

1.Initialize websocket, the original initialization code is as follows

static const httpd_uri_t page = {
.uri = "/",
.method = HTTP_GET,
.handler = page_get_handler,
.user_ctx = NULL,
.is_websocket = true
};
static const httpd_uri_t ctrl = {
.uri = "/ws/
",
.method = HTTP_GET,
.handler = ctrl_post_handler,
.user_ctx = NULL,
.is_websocket = true

};

static const httpd_uri_t timer = {
.uri = "/timer/*",
.method = HTTP_GET,
.handler = channel_get_handler,
.user_ctx = NULL,
.is_websocket = true

};

static void stop_webserver(httpd_handle_t server)
{
// Stop the httpd server
httpd_stop(server);
}

static httpd_handle_t start_webserver(void)
{
httpd_handle_t start_server = NULL;
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.server_port = 80;
config.stack_size = 8192;
config.lru_purge_enable =true;
config.max_uri_handlers =5;
// Start the httpd server
config.uri_match_fn = httpd_uri_match_wildcard;
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
if (httpd_start(&start_server, &config) == ESP_OK)
{
// Registering the ws handler
ESP_LOGI(TAG, "Registering URI handlers");
httpd_register_uri_handler(start_server, &timer);
httpd_register_uri_handler(start_server, &ctrl);
httpd_register_uri_handler(start_server, &page);
return start_server;
}

ESP_LOGI(TAG, "Error starting server!");
return NULL;

}

static void disconnect_handler(void * arg, esp_event_base_t event_base, int32_t event_id, void * event_data)
{
httpd_handle_t * server = (httpd_handle_t *) arg;
if (*server)
{
stop_webserver(*server);
*server = NULL;
}
}
static void connect_handler(void * arg, esp_event_base_t event_base, int32_t event_id, void * event_data)
{
httpd_handle_t * server = (httpd_handle_t *) arg;
if (*server == NULL)
{
ESP_LOGI(TAG, "Starting webserver");
*server = start_webserver();
}
}

void ir_http_init()
{
static httpd_handle_t server = NULL;
esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, &server);
esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, &server);
server = start_webserver();
}

  1. Initialize spiffs and Create a thread to read the contents of uart
    3.Then after trying to restart the device 100 times, the error occurred on the 64th time.The following error content
    I (4330) WEB-SOCKET: Starting server on port: '80'
    I (4330) WEB-SOCKET: Registering URI handlers
    (4330) main_task: Returned from app_main()
    I (4580) message: period_500ms_count value is 4
    I (5580) message: period_500ms_count value is 5
    I (6580) message: period_500ms_count value is 6
    I (7580) message: period_500ms_count value is 7
    I (8580) message: period_500ms_count value is 8
    I (9580) message: period_500ms_count value is 9
    I (10580) message: period_500ms_count value is 10
    I (11580) message: period_500ms_count value is 11
    I (11580) message: Cleaning value not erase_flash.........
    E (11590) httpd: httpd_server: error in select (9)
    W (11590) httpd_sess: enum_function: Closing invalid socket -1
    W (11600) httpd_sess: enum_function: Closing invalid socket -1
    W (11600) httpd_sess: enum_function: Closing invalid socket -1
    W (11610) httpd_sess: enum_function: Closing invalid socket -1
    W (11620) httpd_sess: enum_function: Closing invalid socket -1
    W (11620) httpd_sess: enum_function: Closing invalid socket -1
    W (11630) httpd_sess: enum_function: Closing invalid socket -1
    E (11640) httpd: httpd_server: error in select (9)
    W (11640) httpd_sess: enum_function: Closing invalid socket -1
    W (11650) httpd_sess: enum_function: Closing invalid socket -1
    W (11650) httpd_sess: enum_function: Closing invalid socket -1
    W (11660) httpd_sess: enum_function: Closing invalid socket -1
    W (11670) httpd_sess: enum_function: Closing invalid socket -1
    W (11670) httpd_sess: enum_function: Closing invalid socket -1
    W (11680) httpd_sess: enum_function: Closing invalid socket -1
    E (11690) httpd: httpd_server: error in select (9)
    W (11690) httpd_sess: enum_function: Closing invalid socket -1
    W (11700) httpd_sess: enum_function: Closing invalid socket -1
    W (11710) httpd_sess: enum_function: Closing invalid socket -1
    W (11710) httpd_sess: enum_function: Closing invalid socket -1
    W (11720) httpd_sess: enum_function: Closing invalid socket -1
    W (11720) httpd_sess: enum_function: Closing invalid socket -1
    W (11730) httpd_sess: enum_function: Closing invalid socket -1
    E (11740) httpd: httpd_server: error in select (9)
    W (11740) httpd_sess: enum_function: Closing invalid socket -1
    W (11750) httpd_sess: enum_function: Closing invalid socket -1
    W (11760) httpd_sess: enum_function: Closing invalid socket -1
    W (11760) httpd_sess: enum_function: Closing invalid socket -1
    W (11770) httpd_sess: enum_function: Closing invalid socket -1
    W (11780) httpd_sess: enum_function: Closing invalid socket -1
    W (11780) httpd_sess: enum_function: Closing invalid socket -1
    E (11790) httpd: httpd_server: error in select (9)
    W (11790) httpd_sess: enum_function: Closing invalid socket -1
    W (11800) httpd_sess: enum_function: Closing invalid socket -1
    W (11810) httpd_sess: enum_function: Closing invalid socket -1
    W (11810) httpd_sess: enum_function: Closing invalid socket -1
    W (11820) httpd_sess: enum_function: Closing invalid socket -1
    W (11830) httpd_sess: enum_function: Closing invalid socket -1
    W (11830) httpd_sess: enum_function: Closing invalid socket -1
    E (11840) httpd: httpd_server: error in select (9)
    W (11850) httpd_sess: enum_function: Closing invalid socket -1
    W (11850) httpd_sess: enum_function: Closing invalid socket -1
    W (11860) httpd_sess: enum_function: Closing invalid socket -1
    W (11860) httpd_sess: enum_function: Closing invalid socket -1
    W (11870) httpd_sess: enum_function: Closing invalid socket -1
    W (11880) httpd_sess: enum_function: Closing invalid socket -1
    W (11880) httpd_sess: enum_function: Closing invalid socket -1
    E (11890) httpd: httpd_server: error in select (9)
    W (11900) httpd_sess: enum_function: Closing invalid socket -1
    W (11900) httpd_sess: enum_function: Closing invalid socket -1
    W (11910) httpd_sess: enum_function: Closing invalid socket -1
    W (11920) httpd_sess: enum_function: Closing invalid socket -1
    W (11920) httpd_sess: enum_function: Closing invalid socket -1
    W (11930) httpd_sess: enum_function: Closing invalid socket -1
    W (11940) httpd_sess: enum_function: Closing invalid socket -1
    E (11940) httpd: httpd_server: error in select (9)
    W (11950) httpd_sess: enum_function: Closing invalid socket -1
    W (11950) httpd_sess: enum_function: Closing invalid socket -1
    W (11960) httpd_sess: enum_function: Closing invalid socket -1
    W (11970) httpd_sess: enum_function: Closing invalid socket -1
    W (11970) httpd_sess: enum_function: Closing invalid socket -1
    W (11980) httpd_sess: enum_function: Closing invalid socket -1
    W (11990) httpd_sess: enum_function: Closing invalid socket -1
    E (11990) httpd: httpd_server: error in select (9)
    W (12000) httpd_sess: enum_function: Closing invalid socket -1
    W (12010) httpd_sess: enum_function: Closing invalid socket -1
    W (12010) httpd_sess: enum_function: Closing invalid socket -1
    W (12020) httpd_sess: enum_function: Closing invalid socket -1
    W (12020) httpd_sess: enum_function: Closing invalid socket -1
    W (12030) httpd_sess: enum_function: Closing invalid socket -1
    W (12040) httpd_sess: enum_function: Closing invalid socket -1
    E (12040) httpd: httpd_server: error in select (9)
    W (12050) httpd_sess: enum_function: Closing invalid socket -1
    W (12060) httpd_sess: enum_function: Closing invalid socket -1
    W (12060) httpd_sess: enum_function: Closing invalid socket -1
    W (12070) httpd_sess: enum_function: Closing invalid socket -1
    W (12080) httpd_sess: enum_function: Closing invalid socket -1
    W (12080) httpd_sess: enum_function: Closing invalid socket -1
    W (12090) httpd_sess: enum_function: Closing invalid socket -1
    E (12100) httpd: httpd_server: error in select (9)
    W (12100) httpd_sess: enum_function: Closing invalid socket -1
    W (12110) httpd_sess: enum_function: Closing invalid socket -1
    W (12110) httpd_sess: enum_function: Closing invalid socket -1
    W (12120) httpd_sess: enum_function: Closing invalid socket -1
    W (12130) httpd_sess: enum_function: Closing invalid socket -1
    W (12130) httpd_sess: enum_function: Closing invalid socket -1
    W (12140) httpd_sess: enum_function: Closing invalid socket -1
    E (12150) httpd: httpd_server: error in select (9)
    W (12150) httpd_sess: enum_function: Closing invalid socket -1
    W (12160) httpd_sess: enum_function: Closing invalid socket -1
    W (12160) httpd_sess: enum_function: Closing invalid socket -1
    W (12170) httpd_sess: enum_function: Closing invalid socket -1
    W (12180) httpd_sess: enum_function: Closing invalid socket -1
    W (12180) httpd_sess: enum_function: Closing invalid socket -1
    W (12190) httpd_sess: enum_function: Closing invalid socket -1
    E (12200) httpd: httpd_server: error in select (9)
    W (12200) httpd_sess: enum_function: Closing invalid socket -1
    W (12210) httpd_sess: enum_function: Closing invalid socket -1
    W (12220) httpd_sess: enum_function: Closing invalid socket -1
    W (12220) httpd_sess: enum_function: Closing invalid socket -1
    W (12230) httpd_sess: enum_function: Closing invalid socket -1
    W (12240) httpd_sess: enum_function: Closing invalid socket -1
    W (12240) httpd_sess: enum_function: Closing invalid socket -1
    E (12250) httpd: httpd_server: error in select (9)
    W (12250) httpd_sess: enum_function: Closing invalid socket -1
    W (12260) httpd_sess: enum_function: Closing invalid socket -1
    W (12270) httpd_sess: enum_function: Closing invalid socket -1
    W (12270) httpd_sess: enum_function: Closing invalid socket -1
    W (12280) httpd_sess: enum_function: Closing invalid socket -1
    W (12290) httpd_sess: enum_function: Closing invalid socket -1
    W (12290) httpd_sess: enum_function: Closing invalid socket -1
    E (12300) httpd: httpd_server: error in select (9)
    W (12300) httpd_sess: enum_function: Closing invalid socket -1
    W (12310) httpd_sess: enum_function: Closing invalid socket -1
    W (12320) httpd_sess: enum_function: Closing invalid socket -1
    W (12320) httpd_sess: enum_function: Closing invalid socket -1
    W (12330) httpd_sess: enum_function: Closing invalid socket -1
    W (12340) httpd_sess: enum_function: Closing invalid socket -1
    W (12340) httpd_sess: enum_function: Closing invalid socket -1
    E (16580) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
    E (16580) task_wdt: - IDLE (CPU 0)
    E (16580) task_wdt: Tasks currently running:
    E (16580) task_wdt: CPU 0: httpd
    E (16580) task_wdt: Print CPU 0 (current core) registers
    Stack dump detected
    Core 0 register dump:
    MEPC : 0x4038ad6a RA : 0x4038fe52 SP : 0x3fcd39e0 GP : 0x3fc95200
    0x4038ad6a: xQueueSemaphoreTake at /Users/ko_hon/tool/esp-idf/components/freertos/FreeRTOS-Kernel/queue.c:1657
    0x4038fe52: esp_log_impl_lock_timeout at /Users/ko_hon/tool/esp-idf/components/log/log_freertos.c:48

TP : 0x3fc9607c T0 : 0x420f7430 T1 : 0x4200540a T2 : 0xffffffff
0x420f7430: httpd_sess_delete_invalid at /Users/ko_hon/tool/esp-idf/components/esp_http_server/src/httpd_sess.c:347
0x4200540a: esp_vfs_close at /Users/ko_hon/tool/esp-idf/components/vfs/vfs.c:516

S0/FP : 0x3fca7000 S1 : 0x3fcd3a7c A0 : 0x3fca981c A1 : 0x00000001
A2 : 0x3c163f90 A3 : 0x00000004 A4 : 0x00000002 A5 : 0x00000001
A6 : 0xffffffff A7 : 0x0000000a S2 : 0x00000002 S3 : 0x3c163f48
S4 : 0x420f6000 S5 : 0x3c164000 S6 : 0x3c163000 S7 : 0x00000000
0x420f6000: esp_http_client_perform at /Users/ko_hon/tool/esp-idf/components/esp_http_client/esp_http_client.c:1326

S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x00000000 T4 : 0x00000000 T5 : 0x00000000 T6 : 0x00000000
MSTATUS : 0x3fc94cb0 MTVEC : 0x3fca4060 MCAUSE : 0x00000037 MTVAL : 0x00000001
MHARTID : 0x00000000
W (16580) httpd_sess: enum_function: Closing invalid socket -1
E (16690) httpd: httpd_server: error in select (9)

@wolen666
Copy link
Author

The git branch I use is commit e3e112e (HEAD -> release/v5.1, origin/release/v5.1)

@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 16, 2024
@github-actions github-actions bot changed the title After initializing websocket, the error httpd: httpd_server: error in select (9) will appear. After initializing websocket, the error httpd: httpd_server: error in select (9) will appear. (IDFGH-14242) Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

No branches or pull requests

3 participants