Comments (4)
could you check that pull request #142 ?
from arduinowebsockets.
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.
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.
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)
- How to get a reference of the web socket client that dispatched the msg callback
- Hieromon/AutoConnect & WebSockets Client on ESP8266 - Can't Establish wss
- Secured-ESP8266-Client can't seem to receive any messages while connection is open HOT 1
- Compilation error: 'WebsocketsClient' does not name a type ?? HOT 3
- Getting a error from the TCPServer using the Arduino GIGA R1 WIFI on the ESP-32Client code. HOT 10
- ESP32-CAM WebSocket Server: Failure to Stream Camera Feed after Page Refresh or Multiple Connections
- WSS Connection error
- [ 5236][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number" HOT 2
- Reconnecting after lost connection HOT 2
- Disconnecting almost inmediately
- Random disconnects, fails on binary ping including 0x00 HOT 1
- Esp32 WebSocket Client won't work with WebSocket Node.js server. HOT 3
- Client-Message-Buffer
- ESP32 Server disconnected when receiving messages HOT 1
- Compilation errors with arduino_esp32 version 3.0.0 HOT 6
- wrong username
- Project is dead
- network::TcpServer* _server HOT 1
- Getting my connection closed when on node js wss server HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinowebsockets.