esp-idf: (IDF Websocket client) - TRANSPORT_WS: Sec-WebSocket-Accept not found (IDFGH-11911)

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Board

ESP32-Wrover

Device Description

A custom device

Hardware Configuration

A custom hardware

Version

latest master (checkout manually)

IDE Name

PlatformIO

Operating System

Windows10

Flash frequency

80

PSRAM enabled

yes

Upload speed

115200

Disclaimer

I’m using Arduino framework but i want to use the native IDF websocket client.

Description

The problem I’m facing is that i can’t connect to my node.js server which is in the cloud with native websocket client. It works if my server is running on local, but i can connect to the server with Postman regardless if it is in the cloud or not. I’m hosting my server at onrender.com.

Server is fine because it works if i connect to it with postman or frontend js

Sketch

#include <Arduino.h>
#include <esp_websocket_client.h>

void initWs(){
    esp_websocket_client_handle_t client;
    esp_websocket_client_config_t config = {};
   
    // config.uri = "ws://bridgetest-9q8c.onrender.com" // Doesn't matter if i set it or not.
    config.host = "ws://bridgetest-9q8c.onrender.com"; // Just a simple test server
    // config.port = 80; // Doesn't matter if i set it or not.
    config.transport = WEBSOCKET_TRANSPORT_OVER_TCP; // Doesn't matter if i set it or not.
    // config.subprotocol = "Websocket" // Doesn't matter if i set it or not.

    client = esp_websocket_client_init(&config);
    esp_websocket_register_events(
        client,
        WEBSOCKET_EVENT_ANY,
        reinterpret_cast<esp_event_handler_t>(eventHandler),
        static_cast<void*>(this)
    );
    esp_websocket_client_start(client);
}

Debug Message

E (260241) TRANSPORT_WS: Sec-WebSocket-Accept not found
E (260241) WEBSOCKET_CLIENT: Error transport connect

Other Steps to Reproduce

As i said, i have tried with Postman and with various ws client simulators and it works on every way except my ESP32.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 60

Most upvoted comments

I am not familiar with Arduino. And i use IDF websocket client, it is ok for me to connect your URL. So could you please try IDF websocket client?