You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serial.println("Connecting to Websockets server...");
while (!client.connect(websockets_server, websockets_port, websockets_path)) {
Serial.println("Failed to connect to Websockets server");
delay(5000);
}
Hi. Please help me understand why I am getting this error message.
The hardware is an ESP32.
"Compilation error: 'WebsocketsClient' does not name a type"
`
#include <WiFi.h>
#include <ArduinoWebsockets.h>
const char* ssid = "YourWiFiSSID";
const char* password = "YourWiFiPassword";
const char* websockets_server = "websocket-api.tibber.com";
const int websockets_port = 443;
const char* websockets_path = "/v1-beta/gql/subscriptions";
const char* tibber_token = "YourTibberToken";
WebsocketsClient client;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
client.setAuthorization("Bearer " + String(tibber_token));
client.setInsecure();
client.setReconnectInterval(5000);
Serial.println("Connecting to Websockets server...");
while (!client.connect(websockets_server, websockets_port, websockets_path)) {
Serial.println("Failed to connect to Websockets server");
delay(5000);
}
Serial.println("Connected to Websockets server");
String subscription = "{ "type": "subscription", "query": "subscription { liveMeasurement(homeId: \"\") { timestamp power consumption } }" }";
client.send(subscription);
}
void loop() {
client.poll();
while (client.available()) {
String data = client.readString();
Serial.println(data);
}
}
`
The text was updated successfully, but these errors were encountered: