Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp8266 unable to connect websocket server wss://xyz.com #849

Open
yusufkhan08070817 opened this issue Oct 30, 2023 · 1 comment
Open

esp8266 unable to connect websocket server wss://xyz.com #849

yusufkhan08070817 opened this issue Oct 30, 2023 · 1 comment

Comments

@yusufkhan08070817
Copy link

#include <ESP8266WiFi.h>
#include <WebSocketsClient.h>

const char* ssid = "Net";
const char* password = "12345678";
const char* webSocketServer = "wss://websocket-27cf.onrender.com";

WebSocketsClient webSocket;

void webSocketEvent(WStype_t type, uint8_t* payload, size_t length) {
switch(type) {
case WStype_DISCONNECTED:
Serial.println("Disconnected from the server");
break;
case WStype_CONNECTED:
Serial.println("Connected to the server");
break;
case WStype_TEXT:
Serial.print("Received payload: ");
for(size_t i = 0; i < length; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
break;
case WStype_BIN:
Serial.println("Received binary data");
break;
case WStype_PING:
Serial.println("Received ping from server");
break;
case WStype_PONG:
Serial.println("Received pong from server");
break;
}
}

void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}

//webSocket.beginSSL(webSocketServer,10000);
webSocket.beginSSL("websocket-27cf.onrender.com", 10000, "/");
webSocket.onEvent(webSocketEvent);
// webSocket.setReconnectInterval(5000);
// webSocket.enableHeartbeat(15000, 3000);
}

void loop() {
webSocket.loop();
}

@sadeeqdev
Copy link

I am having the same problem. Were you able to connect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants