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
Secure WSS; how do I create more than one server?(SOLVED!)
Secure WSS; how do I create more than one server?(SOLVED!)
Last edited by BenBurger on Thu Sep 28, 2023 4:11 pm, edited 1 time in total.
-
- Posts: 1701
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Secure WSS; how do I create more than one server?
Try and give each server instance its own control port:E (4967) httpd: httpd_server_init: error in creating ctrl socket (112)
Code: Select all
httpd_ssl_config_t conf = HTTPD_SSL_CONFIG_DEFAULT();
...
conf.httpd.ctrl_port = conf.httpd.ctrl_port + (my_server_instance_number++);
...
Re: Secure WSS; how do I create more than one server?
Thanks tried it, something changed, now the error also changed
I (4967) esp_https_server: Starting server
E (4967) httpd: httpd_server_init: error in creating msg socket (23)
I (4977) : Error starting server!
I (4967) esp_https_server: Starting server
E (4967) httpd: httpd_server_init: error in creating msg socket (23)
I (4977) : Error starting server!
Re: Secure WSS; how do I create more than one server? (SOLVED!!)
Ah found the issues !!!!
LWIP Max number of open sockets : was 5 set it to 10 and now working
seems each socket needs (sockets + 3)*2 ===>
comment in httpd_main.c
.......................................
/* Sanity check about whether LWIP is configured for providing the
* maximum number of open sockets sufficient for the server. Though,
* this check doesn't guarantee that many sockets will actually be
* available at runtime as other processes may use up some sockets.
* Note that server also uses 3 sockets for its internal use :
* 1) listening for new TCP connections
* 2) for sending control messages over UDP
* 3) for receiving control messages over UDP
* So the total number of required sockets is max_open_sockets + 3
*/
LWIP Max number of open sockets : was 5 set it to 10 and now working
seems each socket needs (sockets + 3)*2 ===>
comment in httpd_main.c
.......................................
/* Sanity check about whether LWIP is configured for providing the
* maximum number of open sockets sufficient for the server. Though,
* this check doesn't guarantee that many sockets will actually be
* available at runtime as other processes may use up some sockets.
* Note that server also uses 3 sockets for its internal use :
* 1) listening for new TCP connections
* 2) for sending control messages over UDP
* 3) for receiving control messages over UDP
* So the total number of required sockets is max_open_sockets + 3
*/
Who is online
Users browsing this forum: Gaston1980, Google [Bot], Majestic-12 [Bot] and 258 guests