Links2004 / arduinoWebSockets

arduinoWebSockets
GNU Lesser General Public License v2.1
1.89k stars 555 forks source link

SSL Connection not working #886

Open Sumis34 opened 4 months ago

Sumis34 commented 4 months ago

I'm using this code her with Aduino IDE in VSCode and a ESP 32. When i try to connect to the Server with SSL it dose not work.

Am I missing something?

void setup() {
    WiFi.mode(WIFI_STA);
    WiFi.setHostname(hostname.c_str());
    Serial.begin(115200);
    WiFiManager wm;

    bool res = wm.autoConnect("Glowb Setup");

    if (!res) {
        Serial.println("Failed to connect");
        // ESP.restart();
    } else {
        // if you get here you have connected to the WiFi
        Serial.println("connected...yeey :)");
    }

    String macAddress = String(ESP.getEfuseMac(), HEX);

    setClock();

    // DEV MODE
    //  ws.begin("192.168.1.127", 5005, "/ws?id=" + macAddress);

    // PROD MODE
    const char* url = ("/ws?id=" + macAddress).c_str();
    ws.beginSSL("example.ch", 443, url, NULL, "");

    // event handler
    ws.onEvent(webSocketEvent);

    // try ever 5000 again if connection has failed
    ws.setReconnectInterval(5000);
}
la-elias commented 2 weeks ago

try with ws.beginSSL("example.ch", 443, url);