[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:
>Andy,
>
>I have one more quick question regarding mbedtls behavior.
>Given that one TLS frame may be fragmented at TCP layer, mbedtls might
>need
>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
>is
>> > 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
>optimized
>> > 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
>coming,
>> you should look at HTTP/2.  It can provide all your assets like
>pictures
>> etc on the same TLS connection.  This works well on ESP32 it should
>work
>> on your box.
>>
>> > For flash I/O, might need to sacrifice RAM by maintaining another
>copy
>> > 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
>thread
>> + rx flow control.
>>
>> > Have you helped with other guys on similar topics before, i.e.,
>porting
>> > 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.

-Andy


More information about the Libwebsockets mailing list