[Libwebsockets] sporadic connection close on Rx

Andy Green andy at warmcat.com
Fri Nov 5 10:10:56 CET 2021



On 11/5/21 08:41, Roman Nikiforov wrote:
> On 11/4/21 5:46 PM, Andy Green wrote:
>>
>> Does this problem go away if you disable permessage-deflate at either 
>> the sender or the receiver?
>>
> It seems lws has extensions disabled by default. I tried to add this code
> 
>          const struct lws_extension extensions[] = {                 { 
>                          "permessage-deflate",                         
> lws_extension_callback_pm_deflate,                         
> "permessage-deflate"                          "; 
> client_no_context_takeover"                          "; 
> client_max_window_bits"                 },                 { NULL, NULL, 
> NULL /* terminator */ }         };         contextInfo.extensions = 
> extensions; and got "undefined reference to 
> `lws_extension_callback_pm_deflate'".
> 
> Call to lwsl_wsi_ext(wsi, "post inflate ebuf in len %d / out len 
> %d",...) is outside of
> 
> #if !defined(LWS_WITHOUT_EXTENSIONS)
> 
> and thus log message "post inflate ebuf" visible without extensions 
> turned on.
> 
>> Is lws also doing the sending?
> No, server side uses QWebSocketServer and according to docs extensions 
> are not supported.

I guess I got the wrong idea about compression extension from the 
log.... the problem is starting here

[2021/11/04 13:10:50:3493] I: illegal rsv bits set

there are some ws framing bits that cannot be legally set, if seen, it 
implies we have lost framing sync.  Dropping the unhandled 1868 rx is a 
reaction to that.

It looks like multiple ws fragments are coalesced at the read, but that 
is normal and it seems to deal with it correctly.  but after the frame 
end boundary, there is no valid ws framing afterwards.  tcp + TLS means 
we can't easily lose things and if there was an lws bug here, we would 
be hearing a lot about it I would expect.

What I suggest is enable the cmake option LWS_TLS_LOG_PLAINTEXT_RX and 
see what is actually read from the server, and if we can see the 
breakage, confirm what the server thinks it sent on tls for those packets.

-Andy

> --
> 
> Roman
> 


More information about the Libwebsockets mailing list