Comments (9)
Hi Alexander,
First of all, I really appreciate the helpful attitude, thanks!
That's really interesting... I wonder if it is because wscat returns some weird answer in that case or if its a problem with the esp32 or library impl itself.
I will look into it. Thank you for the detailed issue.
Gil.
from arduinowebsockets.
So I ran few tests:
- The crash seems to be in esp32's function
WiFiClient.read()
(without any params, which should read one byte). - The same scenario with another server impl does not crash the esp
I will keep you updated if I have any more information. Currently I'm not convinced that it's a library problem.
Gil 😃
from arduinowebsockets.
Interesting, I'll use your code tomorrow to try a few stuffs. I wonder if using .read()
will crash (because this is what's crashing in the library). Also it's interesting that connected
returns true after reset (if I understand correctly).
Thanks for the details, I'll let you know tomorrow if I learnt anything new.
Gil :)
from arduinowebsockets.
Closed :)
from arduinowebsockets.
Interesting, so you were able to reproduce the behaviour? I also don't think that it's a library problem actually but maybe some workaround could be implemented. I'm very curious to know what the difference is on TCP level in the different scenarios. Could maybe be investigated with Wireshark somehow.
With more info maybe it should be reported to Espressif?
from arduinowebsockets.
Hmm, just thought of something. We should try the same thing using only wifi-client and regular netcat. I will do so when I get back if you don't get to it before me.
from arduinowebsockets.
OK, interesting. I could not reproduce the crash using only WiFiClient and netcat.
Both reading and writing just fails silently when the arduino is connected to the "dead" socket. Also client.connected() returns true until I terminate the netcat program.
Here is the code I used:
#include <WiFi.h>
const char* ssid = "";
const char* password = "";
const char* host = "";
int port = 1234;
WiFiClient client;
void setup()
{
Serial.begin(115200);
delay(10);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
if (!client.connect(host, port)) {
Serial.println("connection failed");
return;
}
}
void loop()
{
if (client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);
} else if (!client.connected()) {
Serial.println("Not connected");
}
client.print("hello");
delay(1000);
}
from arduinowebsockets.
Hi,
So as you can see in the commit message I made a change that partially solves this issue. Now the client will not crash, it will just not connect to the server.
This is a good first step, but yet it's not possible to reconnect after such reset. It seems like it has more to do with Arduino internals and server impl and less with the library itself.
Let me know how the new code works for you, do you also not get a crash?
Gil.
from arduinowebsockets.
Works much better for me! I'm super happy with the board not crashing and ending up in my reconnect loop. Then if wscat tries to send something it detects that the client has disconnected and somehow starts to listen again and then the board can connect.
Great work!
from arduinowebsockets.
Related Issues (20)
- How to keep receiving messages in server HOT 23
- question of example
- Websocket Client Became Slower and Unstable After Upgrading ESP32 from 1.0.4 to 1.0.6 HOT 1
- Websocket server memory leak
- Can we get a documentation/wiki? HOT 1
- where to find certificate Eg: echo_org_ssl_ca_cert[] HOT 1
- ESP32-Server Not Working Properly receives one msg and gets disconnected HOT 3
- How to know hostname and IP from client? HOT 1
- esp32 to wss python server
- ESP32 Websocket Client doesn't connect to Node.js Websocket server HOT 3
- poll() disconnects client HOT 7
- How to get a reference of the web socket client that dispatched the msg callback
- Hieromon/AutoConnect & WebSockets Client on ESP8266 - Can't Establish wss
- Secured-ESP8266-Client can't seem to receive any messages while connection is open HOT 1
- Compilation error: 'WebsocketsClient' does not name a type ?? HOT 3
- Getting a error from the TCPServer using the Arduino GIGA R1 WIFI on the ESP-32Client code. HOT 3
- ESP32-CAM WebSocket Server: Failure to Stream Camera Feed after Page Refresh or Multiple Connections
- WSS Connection error
- [ 5236][E][WiFiClient.cpp:313] setSocketOption(): fail on -1, errno: 9, "Bad file number" HOT 2
- Reconnecting after lost connection HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinowebsockets.