warmcat / libwebsockets

canonical libwebsockets.org networking library
https://libwebsockets.org
Other
4.73k stars 1.48k forks source link

Serving multiple files over https #3136

Open Somritag opened 4 months ago

Somritag commented 4 months ago

Hi,

I am using version of libwebsocket: 4.3.2 Ported the library to work with MBEDTLS 3.4.1 + LWIP 2.1.2 for STM32H5 series processor for Websocket + webserver services As per the environment setup, FREERTOS is being used.

Has taken the reference for setting up the config file from (https://github.com/tushartp/STM32H7-Webserver) Not using any other libraries for external polling, using internal polling. Using port 443 for https and wss

context_settings

Issue : The web communication is happening using Role HTTP2 Was referring minimal-http-server-form-post.c, for loading a webpage for our webUI implementation, observed the file size > 1kb often getting timed out while serving the page. It hits lws_service_adjust_timeout() ---> __lws_sul_service_ripe()---->lws_sul_wsitimeout_cb() For testing was using leaf.jpg (size 2.5 MB ). Most of the times after 120Bytes transfer its timing out. I have not set any timeout while setting the context or creating the lws_service ().

Observation: If we open the socket on the same port then query the page, it doesn't get time out but loading speed is very slow. (takes around 29.19s at times to load 2.5 Mb leaf image, bigger file takes much more longer duration)

Is there some additional configuration am missing out , while serving the pages without establishing the socket connection which lead to timeouts.

Kindly guide for the best practice to serve multiple files back to back for the webserver.

Thanks, s

lws-team commented 4 months ago

You shouldn't need any sleeps (5 what... seconds, ms...) around the service loop. It will stick in the service wait until something happens.

Timeouts can only happen by that calling pattern.

You should look at the verbose lws logs and see how it feels stuff is happening.

There are more suspicious characters than usual since its your own-built lwip. The logs might help give a clue.