Secure WSS; how do I create more than one server?(SOLVED!)
Posted: Wed Sep 27, 2023 7:33 pm
Hi all
Can anyone help with WSS socket server
I want to create 2 servers sending different data on 2 different ports 9000 and 443 for now
HOWEVER the first one works but never the second one
I (4957) : Starting server
I (4957) esp_https_server: Starting server
I (4957) esp_https_server: Server listening on port 443
I (4957) : Registering URI handlers
I (4957) : Starting server
I (4967) esp_https_server: Starting server
E (4967) httpd: httpd_server_init: error in creating ctrl socket (112)
I (4977) : Error starting server!
I have duplicated almost all the functions yet it fails
.............................
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
conf.httpd.max_open_sockets = max_clients;
conf.httpd.global_user_ctx = keep_alive;
conf.port_secure = 9000;
conf.httpd.open_fn = wss_open_fd1;
conf.httpd.close_fn = wss_close_fd1;
....................
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
conf.httpd.max_open_sockets = max_clients;
conf.httpd.global_user_ctx = keep_alive;
conf.port_secure = 443;
conf.httpd.open_fn = wss_open_fd;
conf.httpd.close_fn = wss_close_fd;
#ifdef CONFIG_EXAMPLE_CONNECT_WIFI
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, &server));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, &server));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler1, &server1));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler1, &server1));
#endif // CONFIG_EXAMPLE_CONNECT_WIFI
/* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
* Read "Establishing Wi-Fi or Ethernet Connection" section in
* examples/protocols/README.md for more information about this function.
*/
ESP_ERROR_CHECK(example_connect());
/* This function demonstrates periodic sending Websocket messages
* to all connected clients to this server
*/
wss_server_send_messages(&server);
wss_server_send_messages1(&server1);
Any help will be appreciated what am I missing here
tx
Ben
Can anyone help with WSS socket server
I want to create 2 servers sending different data on 2 different ports 9000 and 443 for now
HOWEVER the first one works but never the second one
I (4957) : Starting server
I (4957) esp_https_server: Starting server
I (4957) esp_https_server: Server listening on port 443
I (4957) : Registering URI handlers
I (4957) : Starting server
I (4967) esp_https_server: Starting server
E (4967) httpd: httpd_server_init: error in creating ctrl socket (112)
I (4977) : Error starting server!
I have duplicated almost all the functions yet it fails
.............................
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
conf.httpd.max_open_sockets = max_clients;
conf.httpd.global_user_ctx = keep_alive;
conf.port_secure = 9000;
conf.httpd.open_fn = wss_open_fd1;
conf.httpd.close_fn = wss_close_fd1;
....................
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
conf.httpd.max_open_sockets = max_clients;
conf.httpd.global_user_ctx = keep_alive;
conf.port_secure = 443;
conf.httpd.open_fn = wss_open_fd;
conf.httpd.close_fn = wss_close_fd;
#ifdef CONFIG_EXAMPLE_CONNECT_WIFI
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler, &server));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler, &server));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &connect_handler1, &server1));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &disconnect_handler1, &server1));
#endif // CONFIG_EXAMPLE_CONNECT_WIFI
/* This helper function configures Wi-Fi or Ethernet, as selected in menuconfig.
* Read "Establishing Wi-Fi or Ethernet Connection" section in
* examples/protocols/README.md for more information about this function.
*/
ESP_ERROR_CHECK(example_connect());
/* This function demonstrates periodic sending Websocket messages
* to all connected clients to this server
*/
wss_server_send_messages(&server);
wss_server_send_messages1(&server1);
Any help will be appreciated what am I missing here
tx
Ben