[Libwebsockets] SSL http client stalls on the last chunk.
libws at zevv.nl
Wed Jan 22 12:58:43 CET 2020
I have run into a case (hard to reproduce, so no sample code here,
sorry) where a client HTTPS transfer stalls while waiting for the
last remaining bit of data.
The symptoms are that libws no longer triggers LWS_CALLBACK_RECEIVE_CLIENT_HTTP
events, until the remote server decides it has waited long enough and
closes the socket. This triggers a new LWS_POLLIN, causing the state
machine to run again and the final bits of the tranfer to succeed. It
seems that the chain of events gets lost somewhere if there is more then
one buffer available in the OpenSSL context, this just gets stuck until
the event loop kicks in again.
The comments "if it was our buffer that... this data will sit there
forever" in openssl-ssl.c seem to apply here somehow.
I can workaround this by calling lws_http_client_read() more then once
from the LWS_CALLBACK_RECEIVE_CLIENT_HTTP callback to this makes sure to
drain the OpenSSL decrypted read buffer, but I assume this is not
supposed to work like this.
What am I doing wrong here?
More information about the Libwebsockets