WS frame is not properly masked.

PeterR
Posts: 568
Joined: Mon Jun 04, 2018 2:47 pm

WS frame is not properly masked.

Postby PeterR » Thu Oct 29, 2020 10:24 am

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."));
return ESP_ERR_INVALID_STATE;
}
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?
& I also believe that IDF CAN should be fixed.

PeterR
Posts: 568
Joined: Mon Jun 04, 2018 2:47 pm

Re: WS frame is not properly masked.

Postby PeterR » Mon Nov 02, 2020 11:19 pm

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.
See: https://www.esp32.com/viewtopic.php?f=2&t=17510
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: szguyer and 29 guests