-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Labels
bugSomething isn't workingSomething isn't workingresolvedthe issue was resolvedthe issue was resolved
Description
Hi,
I'm using the code from the Client Example for an SSL server.
Most of it works as expected, however - if I shutdown the WebSocket server I'm connected to or even disconnect the network, no event is being triggered.
Surprisingly, even if i call client.available() it returns true, even though the server is shut down or there's no network connection to it...
I'm using an ESP-WROOM-32 board if and an NGinx WebSocket server. The socket server works without any issue with any browser client (tested EDGE, Firefox, Chrome) and these browsers successfully report a server disconnect or so.
As told, code is the one from the client example:
#include <ArduinoWebsockets.h>
#include <WiFi.h>
const char* ssid = "WiFi Name"; //Enter SSID
const char* password = "WiFi Password"; //Enter Password
const char* websockets_server = "wss://url.com:443/ws/"; //server adress and port
using namespace websockets;
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!");
}
Serial.println("Event triggered...");
}
WebsocketsClient client;
void setup() {
Serial.begin(115200);
// Connect to wifi
WiFi.begin(ssid, password);
// Wait some time to connect to wifi
for(int i = 0; i < 10 && WiFi.status() != WL_CONNECTED; i++) {
Serial.println(".");
delay(1000);
}
Serial.println("Connected to WiFi... probably.");
// Setup Callbacks
client.onMessage(onMessageCallback);
client.onEvent(onEventsCallback);
// Connect to server
client.connect(websockets_server);
// Send a message
client.send("This is a nice little message sent from ESP32.");
}
void loop() {
if (client.available()) {
client.poll();
} else {
Serial.println("OOPS!! Client Disconnected...");
delay(5000);
}
}
If there's any detail I can help you with to debug this issue, just let me know.
All the best,
A.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingresolvedthe issue was resolvedthe issue was resolved