Open ashutosh7777 opened 2 years ago
When the client object goes out of scope, the connection is closed. If you want to keep receiving/sending messages, you should not let the object go out of scope. Instead keep interacting with it until you want it closed. You could check the wiki for more information and advanced examples for handling multiple clients and so on.
ya i tried advance client also issue remains same
same problem here. can't find any solution. @ashutosh7777 did you find any solution?
Same here. It seems that the board is restarting after receiving a message.
Edit: After a series of tests, I realized that in my case, the ESP32 was rebooting due to a lack of power. By adding a new power source to the relay circuit and using only the signal from the ESP32, it stopped rebooting and worked normally.
/****
ESP32-Server.ino For ESP32.
/* Minimal Esp32 Websockets Server
This sketch:
closes the connection and goes back to step 3
Hardware: For this sketch you only need an ESP32 board.
Created 15/02/2019 By Gil Maimon https://github.com/gilmaimon/ArduinoWebsockets */
include
include
const char ssid = "only"; //Enter SSID const char password = "ashu1234"; //Enter Password
using namespace websockets;
WebsocketsServer server; void setup() { Serial.begin(115200); // Connect to wifi WiFi.begin(ssid, password);
// Wait some time to connect to wifi for(int i = 0; i < 15 && WiFi.status() != WL_CONNECTED; i++) { Serial.print("."); delay(1000); }
Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); //You can get IP address assigned to ESP
server.listen(80); Serial.print("Is server live? "); Serial.println(server.available()); }
void loop() { WebsocketsClient client = server.accept(); if(client.available()) { WebsocketsMessage msg = client.readBlocking();
// client.send("Echo: " + msg.data());
// client.close(); }
delay(1000); }
any help will be great for us. thank you in advance