Skip to content

Client disconnected errors with sample code #440

@twinone

Description

@twinone

Testing the following sample code:

#include <Arduino.h>
#include <WebSocketsClient.h>

WebSocketsClient webSocket;

void webSocketEvent(WStype_t type, uint8_t* payload, size_t length) {
    switch (type) {
        case WStype_DISCONNECTED:
            Serial.printf("[WSc] Disconnected!\n");
            break;
        case WStype_CONNECTED:
            Serial.printf("[WSc] Connected to URL: %s\n", payload);
            webSocket.sendTXT("Connected\r\n");
            break;
        case WStype_TEXT:
            Serial.printf("[WSc] get text: %s\n", payload);
            break;
        case WStype_BIN:
            Serial.printf("[WSc] get binary length: %u\n", length);
            break;
    }
}

void setup() {
    Serial.begin(9600);
    WiFi.mode(WIFI_STA);
    WiFi.begin("SSID", "PASS");

    webSocket.beginSSL("echo.websocket.org", 443, "/");
    webSocket.onEvent(webSocketEvent);
}

void loop() {
    delay(500);
    webSocket.loop();
}

Is failing with the following error:

[WSc] Disconnected!
[WSc] Disconnected!

Using PlatformIO & WEMOS D1 mini (ESP8266).

This library has always worked, is there any recent changes that might cause this behavior? I'm not even able to connect to echo.websocket.org.

Thanks for the help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions