Page 1 of 1

WS frame is not properly masked.

Posted: Thu Oct 29, 2020 10:24 am
by PeterR
IDF: SHA-1: 8bc19ba893e5544d571a753d82b44a84799b94b1

Using the ESP IDF web socket server.

Occassionally I get the above warning. Looking at the code:
if (masked) {
if (httpd_recv_with_opt(req, (char *)mask_key, sizeof(mask_key), false) <= 0) {
ESP_LOGW(TAG, LOG_FMT("Failed to receive mask key"));
return ESP_FAIL;
} else {
/* If the WS frame from client to server is not masked, it should be rejected.
* Please refer to RFC6455 Section 5.2 for more details. */
ESP_LOGW(TAG, LOG_FMT("WS frame is not properly masked."));
According to RFC6455 however the frame does not need to be masked:
frame-masked = %x0
; frame is not masked, no frame-masking-key
/ %x1
; frame is masked, frame-masking-key present
; 1 bit in length
What am I supposed to do with this? Do I; ignore, close & restart connection etc?

Re: WS frame is not properly masked.

Posted: Mon Nov 02, 2020 11:19 pm
by PeterR
The answer is: Drop the frame & connection - you cannot recover.
Which is a shame as this seems to fly in the face of a websocket's utility.
In my experience the issue seems related to the ESP32 client sending MQTT packets over multiple WS frames and at some point failing on a malloc.