Open
Description
ESP8266 with Arduino 1.8.13, ArduinoWebsockets 0.5.0
I was reading #75 because I'm having the same probem. I have put my websocket setup calls into its own function:
void onEventsCallback(WebsocketsEvent event, String data) {
if(event == WebsocketsEvent::ConnectionOpened) {
Serial.println("Connnection Opened");
} else if(event == WebsocketsEvent::ConnectionClosed) {
Serial.println("Connnection Closed");
setupWebsocket();
}
}
void setupWebsocket() {
client = {}; // as advised in issue #75
client.onMessage(onMessageCallback);
client.onEvent(onEventsCallback);
client.setInsecure(); // yes, lame
client.connect(websockets_connection_string);
}
void setup() {
// [.. Serial + wifi setup not shown..]
setupWebsocket();
}
This works fine until the remote websocket is closed - my code does not successfully reconnect :( I DO see the Connection Closed
and then shortly after Connection Opened
on the Serial output, but I don't get any new incoming WS messages after that.
What am I doing wrong?