Git Product home page Git Product logo

Comments (4)

mkrasselt1 avatar mkrasselt1 commented on July 19, 2024

could you check that pull request #142 ?

from arduinowebsockets.

JpEncausse avatar JpEncausse commented on July 19, 2024

Hello, I got the same issue here :

[ 11748][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -1
[ 11749][E][WiFiClient.cpp:313] setSocketOption(): fail on 0, errno: 9, "Bad file number"
#include <ArduinoWebsockets.h>
const char* websockets_server_string = "wss://path/to/server"; 

using namespace websockets;
WebsocketsClient client_ws;

unsigned long ws_t1 = 0;
void loopWebSocket(){

  if (client_ws.available()) { client_ws.poll(); }

  unsigned long ws_t0 = millis();
  if (ws_t0 - ws_t1 >= 3000) {
    ws_t1 = ws_t0;
    client_ws.send("Hello, world!");
  } 
}

void onMessageCallback(WebsocketsMessage message) {
    Serial.print("Got Message: ");
    Serial.println(message.data());
}

void onEventsCallback(WebsocketsEvent event, String data) {
    if(event == WebsocketsEvent::ConnectionOpened) {
        Serial.println("Connnection Opened");
    } else if(event == WebsocketsEvent::ConnectionClosed) {
        Serial.println("Connnection Closed");
    } else if(event == WebsocketsEvent::GotPing) {
        Serial.println("Got a Ping!");
    } else if(event == WebsocketsEvent::GotPong) {
        Serial.println("Got a Pong!");
    }
}


const char ssl_ca_cert[] PROGMEM = \
"-----BEGIN CERTIFICATE-----\n" \
"The real certificate"
"-----END CERTIFICATE-----\n";

void Helper::setupWebSocket(){
  delay(2000);

  // run callback when messages are received
  client_ws.onMessage(onMessageCallback);
    
  // run callback when events are occuring
  client_ws.onEvent(onEventsCallback);

  // Before connecting, set the ssl fingerprint of the server
  client_ws.setCACert(ssl_ca_cert);
  client_ws.setInsecure(); // Usefull ?

  bool connected = client_ws.connect(websockets_server_string);
  if (connected) {
      Serial.println("Connected!");
      client_ws.send("Hello Server");
  } else {
      Serial.println("Not Connected!");
  }
}

I don't know what to do ? I almost copy the code sample here.
I also tested my server with another client and it works.

from arduinowebsockets.

JpEncausse avatar JpEncausse commented on July 19, 2024

If I remove the setInsecure() I got another error :

[  7620][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-9984) X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
[  7623][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -9984
[  7630][E][WiFiClient.cpp:313] setSocketOption(): fail on 0, errno: 9, "Bad file number"

I validated my certificate online and it seems ok

-----BEGIN CERTIFICATE-----
MIIELzCCAxegAwIBAgISBKAmUFp/5WC2dl4lllvLlMzCMA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
EwJSMzAeFw0yNDAzMjAxMDMwMjdaFw0yNDA2MTgxMDMwMjZaMCExHzAdBgNVBAMT
Fm92ZXJ3YXRjaC5lbmNhdXNzZS5uZXQwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC
AARrmNadPiJ/a0bL+jaH+i1H+vjpGhIo/WZsLJZseh1OGy6WvdFDqBVlk1b0eFgs
NcPYvrAJFJhx0lT/fVanVd9io4ICGTCCAhUwDgYDVR0PAQH/BAQDAgeAMB0GA1Ud
JQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQW
BBQrrQP44KE+DZQh73mHOw0+Cm0u0TAfBgNVHSMEGDAWgBQULrMXt1hWy65QCUDm
H6+dixTCxjBVBggrBgEFBQcBAQRJMEcwIQYIKwYBBQUHMAGGFWh0dHA6Ly9yMy5v
LmxlbmNyLm9yZzAiBggrBgEFBQcwAoYWaHR0cDovL3IzLmkubGVuY3Iub3JnLzAh
BgNVHREEGjAYghZvdmVyd2F0Y2guZW5jYXVzc2UubmV0MBMGA1UdIAQMMAowCAYG
Z4EMAQIBMIIBBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHYAO1N3dT4tuYBOizBbBv5A
O2fYT8P0x70ADS1yb+H61BcAAAGOW6B5cQAABAMARzBFAiEAqAftZT6S78W2ahO/
JRUprCZQg7euGai3hqCfZ2p8jp8CIBzNaK/2GcPiNvgpT0XMxMgMKZWgtxsinmi4
nyLpuf3FAHcA7s3QZNXbGs7FXLedtM0TojKHRny87N7DUUhZRnEftZsAAAGOW6B6
GwAABAMASDBGAiEAi58d46WuwWK4anmmLyDzRLAnbm2Juw/VnLPL52qoMz8CIQDk
0KkbW/bn5p1vzKGJ2tj4RfZ6hGvawr4WfqN3D+tTNzANBgkqhkiG9w0BAQsFAAOC
AQEAkxKol0ev7MQdrsQf9F1oA13GgxjC6eQ1SjCFvThMvYJjwz9KRdLiYyqxZoIH
Oh55+YF9HtzwsSzGBDtTn9a9HOClwRIL+TRzlJWE3mZadQDzDdYRsRQ7HEq+kpYi
C/FhHyMSE0OTy1IGkmqum1l0lN4fG3a1950ekH/ght7sLIfqhSUHuPRH/a1RPUQ8
QGkl58Fx07O+vv+qGYnxIuUh5r4kusQhYAD73wJZQayyF8mtNWAwdrb8tl1IWLND
pziPju+tW3QFOP0lW+fxWbaAQEOt2AvU1rNSb0USOUoDJdqveNwZZ1GkvroXiRda
CriNjth9OJS7lTgwKINsxlW6Wg==
-----END CERTIFICATE-----

from arduinowebsockets.

JpEncausse avatar JpEncausse commented on July 19, 2024

Find the answer !!!!! YES !!!! (months I got the issue)
Here is the explanation : https://www.esp32.com/viewtopic.php?t=12083
And the Issue : espressif/arduino-esp32#3155

In a nutshell the Certificate Generated by Let's Encrypt suck but it's parent works

from arduinowebsockets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.