Page 1 of 1

What's wrong with this websocket response? (Error read response for Upgrade header)

Posted: Fri Mar 04, 2022 7:10 am
by RichPiano
I'm using the example provided in examples/protocols/websocket to connect to my node.js/socket.io webserver. The websocket module and its associated transport_ws.c however is complaining that it can't read the following http header:

Code: Select all

E (531690) TRANSPORT_WS: Error read response for Upgrade header GET / HTTP/1.1
Connection: Upgrade
Host: <host_censored>:<port_censored>
User-Agent: ESP32 Websocket Client
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: fgofZlF6LAlrSHN8N17X+A==
The header looks valid to me and it also works perfectly with my test javascript socket.io client. Digging down in the code, it seems that the transport_ws.c module issues this error when a deeper call to transport.c's esp_transport_read fails:

Code: Select all

int esp_transport_read(esp_transport_handle_t t, char *buffer, int len, int timeout_ms)
{
    if (t && t->_read) {
        return t->_read(t, buffer, len, timeout_ms);
    }
    return -1;
}
Do I maybe have to adapt my read function?

Re: What's wrong with this websocket response? (Error read response for Upgrade header)

Posted: Mon Mar 07, 2022 3:23 am
by ESP_YJM
You can print errno number value and capture the websocket connection packet.

Re: What's wrong with this websocket response? (Error read response for Upgrade header)

Posted: Mon Dec 12, 2022 8:34 am
by RockSmoke
i am getting the same error. how did you solve this problem