[Libwebsockets] CPU-intensive and I/O-intensive job in LWS

Andy Green andy at warmcat.com
Thu Oct 4 22:08:03 CEST 2018

On October 5, 2018 2:46:18 AM GMT+08:00, Xi Chen <leon6827chix at gmail.com> wrote:
>I have one more quick question regarding mbedtls behavior.
>Given that one TLS frame may be fragmented at TCP layer, mbedtls might
>to call multiple recv() before it can decrypt the packet.
>I do notice that lws_http_client_read eventually calls mbedtls_ssl_read
>which has a handshake loop, i.e., mbedtls_ssl_handshake. Does this mean
>that LWS thread will be blocked until all related TCP segments has been
>received and decryption is done?
>On Thu, Oct 4, 2018 at 12:24 AM Andy Green <andy at warmcat.com> wrote:
>> On 04/10/18 15:06, Xi Chen wrote:
>> > Thanks for your insights Andy.
>> >
>> > Unfortunately the platform is some RTOS running on tiny MCU, which
>> > not powerful at all.
>> Even RTOS have a thread concept though.
>> > The thread pool approach is not possible for me.
>> If it's not pthreads or pthreads-compatible, then no.
>> > For TLS, seems the solution is to speed it up by using other
>> > libraries?
>> Not if mbedtls is the only thing on your platform.  1 x TLS will cost
>> whatever it costs timewise, but if you have multiple connections
>> you should look at HTTP/2.  It can provide all your assets like
>> etc on the same TLS connection.  This works well on ESP32 it should
>> on your box.
>> > For flash I/O, might need to sacrifice RAM by maintaining another
>> > of received data, and write it later to flash by different task?
>> You can do that, or read again more closely about using a second
>> + rx flow control.
>> > Have you helped with other guys on similar topics before, i.e.,
>> > LWS on resource tight platforms? I do notice that there is esp32
>> > support, but not many related sample apps I can find in this area.
>> Nobody pays me to look at it... if people like yourself who feel I
>> should be spending my life doing that or other stuff want to actually
>> fund it (or contribute it directly...), it can happen.

You just ignore this observation... that's pretty rude.


More information about the Libwebsockets mailing list