-
Notifications
You must be signed in to change notification settings - Fork 96
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
ESP-32 panic when trying to connect to the old socket #46
Comments
Hi Alexander, 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. |
So I ran few tests:
I will keep you updated if I have any more information. Currently I'm not convinced that it's a library problem. Gil 😃 |
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? |
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. |
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);
} |
Interesting, I'll use your code tomorrow to try a few stuffs. I wonder if using Thanks for the details, I'll let you know tomorrow if I learnt anything new. Gil :) |
…efore attempting a read. Which solved the crash in issue #46
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. |
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! |
Closed :) |
Hi!
First of all, thanks for this lovely library!
I have found something that is similar to #25
I use https://github.com/websockets/wscat for my development. And start up a server.
The first time, client.connect works.
Also, if I never start the server, client.connect does not crash and I can stay in a client.available loop.
However, if I start the board, it successfully connects to the server. Then reboot the board (without wscat noticing) and it tries to connect to wscat that still thinks it's connected to the previous boot. Then the board crashes.
I have extracted the stacktrace:
Board: Huzzah 32
Websockets: 0.4.11
Wscat: 2.2.1
Don't really know why it behaves differently when trying to connect to a non open port vs a port that I guess "thinks" it's open.
This will probably not cause any issue for me during production when I run with a real server but I would like to contribute to making this library rock-solid in any way I can.
Cheers!
The text was updated successfully, but these errors were encountered: