I'm trying to use an ESP8266 to connect to two WebSocket servers simultaneously using the arduinoWebSockets library. This is a snippet of my code. I then attempt to display data on 7 segment displays.
#include <WebSocketsClient.h>
WebSocketsClient flightWebSocket;
WebSocketsClient cryptoWebSocket;
void setup() {
// Setup WebSocket 1 (Flight Data)
flightWebSocket.beginSSL("****", 443, "/api/ws", NULL, "");
delay(100);
// Setup WebSocket 2 (Crypto Data)
cryptoWebSocket.beginSSL("****", 443, "/prices?assets=bitcoin", NULL, "");
// Enable heartbeat for both WebSockets
flightWebSocket.enableHeartbeat(50000, 5000, 0);
cryptoWebSocket.enableHeartbeat(50000, 5000, 0);
// Set reconnect intervals
flightWebSocket.setReconnectInterval(4000);
cryptoWebSocket.setReconnectInterval(4000);
}
void loop() {
// Call loop for both WebSockets
flightWebSocket.loop();
cryptoWebSocket.loop();
}
Here's the issue:
One WebSocket stays connected, but the second fails to connect repeatedly. When I try the same code on an ESP32, it works perfectly fine. But I would prefer to use a ESP8266 Question Is this issue caused by:
A limitation of the ESP8266 hardware? A limitation in the arduinoWebSockets library's implementation for the ESP8266? Or is there something else I might be overlooking?