warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.78k stars 1.49k forks source link

Webserver and Websocket at same port , Serving pages gets timed OUT #3237

Open Somritag opened 1 month ago

Somritag commented 1 month ago

Hi Andy,

Am using HTTPS and WSS both at port 443,

image

My issue is when am having two pvo : lws-minimal-server-echo, default (snippet above) I can use both webserver and websocket but while serving WEB pages getting ERR_CONNECTION_CLOSED after loading few files image

If I keep only one pvo for the websocket callback,

The webserver load performance is stable but the websocket connection gets open but SEND/RECEIVE does not happen (testing with simple web client)

Creating context as below: image

Protocols defined looks like this: image

Any guidance will help. Thanks

lws-team commented 1 month ago

... lws send out a lot of logs you can use to understand its point of view. You're going to have to look at them...

The commented pvo's job is to tell lws how to route a NULL protocol name request for ws upgrade, in terms of which protocol on the lws side. If the browser side doesn't provide a protocol name with its request, you need to use it to bind the ws connection to the expected protocol / callback.

Somritag commented 3 weeks ago

Hi Andy,

Is there a better approach to handle webServer and websocket using same port 443 with FreeRTOS and STM32/ any example with FREERTOS multi threading to handle webserver/ websocket? Will timer callback for websocket help ? or separate ports for server and websocket will help?? At present am getting ERR_CONECTION_CLOSED after approx 1 mnt of serving bigger files. If websocket is not listening to same port files loading is all fine.

lws-team commented 3 weeks ago

logs...

Somritag commented 3 weeks ago

Attaching the logs.. webserver_loading.txt webserver_websocket_loding.txt

looks like this... when not loaded completely image

lws-team commented 3 weeks ago

lws_h2_goaway: [wsisrv|4|adopted|h1|h2]: ERR 0x1, 'Another stream not allowed'

Does this help?

diff --git a/lib/plat/freertos/freertos-init.c b/lib/plat/freertos/freertos-init.c
index 49f5b5d9..15f0916d 100644
--- a/lib/plat/freertos/freertos-init.c
+++ b/lib/plat/freertos/freertos-init.c
@@ -60,7 +60,7 @@ const struct http2_settings lws_h2_defaults_esp32 = { {
        1,
        /* H2SET_HEADER_TABLE_SIZE */                    512,
        /* H2SET_ENABLE_PUSH */                            0,
-       /* H2SET_MAX_CONCURRENT_STREAMS */                 8,
+       /* H2SET_MAX_CONCURRENT_STREAMS */                 16,
        /* H2SET_INITIAL_WINDOW_SIZE */                    0,
        /* H2SET_MAX_FRAME_SIZE */                     16384,
        /* H2SET_MAX_HEADER_LIST_SIZE */                 512,
Somritag commented 2 weeks ago

This did not help, still having same issue. image Firefox capture... and wire shark... image