Skip to content

(IDF Websocket client) - TRANSPORT_WS: Sec-WebSocket-Accept not found #9120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
zekageri opened this issue Jan 17, 2024 · 6 comments
Closed
1 task done

Comments

@zekageri
Copy link

zekageri commented Jan 17, 2024

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

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.
@zekageri zekageri added the Status: Awaiting triage Issue is waiting for triage label Jan 17, 2024
@zekageri
Copy link
Author

zekageri commented Jan 17, 2024

The server is https but it has an http interface and it does not redirect.
It is reachable with both ws and wss with postman and also with http and https

Server code is a simple ws server

import express from "express";
import http from "http";
import { WebSocketServer } from 'ws';

const app = express();
const server = http.createServer(app);
const wss = new WebSocketServer({ server });

wss.on('connection', function(ws) {
    console.log("Client connected!");

    ws.on('error', console.error);
  
    ws.on('message', function(data) {
      console.log('received: %s', data);
    });

    ws.on("close", function() {
        console.log("Client disconnected!");
    });
  
    setInterval(() => {
        ws.send('Test message');
    }, 5000);
});

server.listen(80, () => {
    console.log(`Server listening on port 80`);
});

@me-no-dev
Copy link
Member

you should ask in the IDF repo. If you are on master here, then you are on IDF v5.1.2

@zekageri
Copy link
Author

Yeah, i figured i should ask it there, so i created an issue.
Strange things happening.

@zekageri
Copy link
Author

zekageri commented Jan 18, 2024

Can i somehow define CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY and CONFIG_ESP_TLS_INSECURE using platformIO?
I have tried to put these into platformio.ini like this

-D CONFIG_ESP_TLS_INSECURE
-D CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY
-D CONFIG_ESP_TLS_INSECURE=1
-D CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=1
-DCONFIG_ESP_TLS_INSECURE
-DCONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY
-DCONFIG_ESP_TLS_INSECURE=1
-DCONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY=1

No success. The websocket client should work if i could define these.
Is this an arduino disadvantage?

@the-programmer
Copy link

Almost a year later...
The issue is that once you are on Arduino/PlatformIO the entire IDF is "fixed" meaning you cannot make any changes to it.
Since Espressif made a change to the way the server verification worked (see #5176 (comment)), it's hard/impossible to get the Arduino platform to work without server verification.

I'm still looking for a way...

@Parsaabasi Parsaabasi removed the Status: Awaiting triage Issue is waiting for triage label Jan 15, 2025
@Parsaabasi
Copy link

Hello,

Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants