When a page with websockets active has a link for another page that needs to establish another websocket connection and the target is the same, ESP crashes.
If the link has target="blank" , this does not occur.
( you might need to try clicking 2 or 3 times in a row to make it happen )
tested on a ESP01 and on NodeMCU (ESP-12E)
I have this simplified code so that it is possible to replicate this bug.
This only happens using safari ( ios or macos ) , Chrome is fine.
`
// Import required libraries
include
include
include
//#include "FS.h" // SPIFFS
// Replace with your network credentials
const char ssid = "YOURSSID";
const char password = "YOUR PASSWORD";
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
AsyncWebSocket ws("/ws");
void onEvent(AsyncWebSocket server, AsyncWebSocketClient client, AwsEventType type,
void arg, uint8_t data, size_t len) {
switch (type) {
case WS_EVT_CONNECT:
Serial.printf("WebSocket client #%u connected from %s\n", client->id(), client->remoteIP().toString().c_str());
break;
case WS_EVT_DISCONNECT:
Serial.printf("WebSocket client #%u disconnected\n", client->id());
break;
case WS_EVT_DATA:
Serial.printf("message incoming");
break;
case WS_EVT_PONG:
break;
case WS_EVT_ERROR:
break;
}
}
Hello,
When a page with websockets active has a link for another page that needs to establish another websocket connection and the target is the same, ESP crashes.
If the link has target="blank" , this does not occur.
( you might need to try clicking 2 or 3 times in a row to make it happen )
tested on a ESP01 and on NodeMCU (ESP-12E)
I have this simplified code so that it is possible to replicate this bug. This only happens using safari ( ios or macos ) , Chrome is fine.
` // Import required libraries
include
include
include
//#include "FS.h" // SPIFFS
// Replace with your network credentials const char ssid = "YOURSSID"; const char password = "YOUR PASSWORD";
// Create AsyncWebServer object on port 80 AsyncWebServer server(80); AsyncWebSocket ws("/ws");
void onEvent(AsyncWebSocket server, AsyncWebSocketClient client, AwsEventType type, void arg, uint8_t data, size_t len) { switch (type) { case WS_EVT_CONNECT: Serial.printf("WebSocket client #%u connected from %s\n", client->id(), client->remoteIP().toString().c_str()); break; case WS_EVT_DISCONNECT: Serial.printf("WebSocket client #%u disconnected\n", client->id()); break; case WS_EVT_DATA: Serial.printf("message incoming"); break; case WS_EVT_PONG: break; case WS_EVT_ERROR: break; } }
const char page1_html[] PROGMEM = R"rawliteral( <!DOCTYPE HTML>
LINK TO 2 - CRASHES
LINK TO 2 - FINE