-
Notifications
You must be signed in to change notification settings - Fork 108
Closed
Labels
resolvedthe issue was resolvedthe issue was resolvedusage queshtionQueshtions about using the library, its interface and so onQueshtions about using the library, its interface and so on
Description
My ESP32 panics when ArduinoWebsockets initiates a websocket connection.
Code running on ESP32:
#include <Arduino.h>
#include <WiFiManager.h>
#include <ArduinoWebsockets.h>
WiFiManager wifiManager;
using namespace websockets;
WebsocketsClient client;
static const char SERVER[] = "ws://192.168.1.149"; // my laptop's IP
void onMessageCallback(WebsocketsMessage message) {
Serial.print("Got Message: ");
Serial.println(message.data());
}
void onEventsCallback(WebsocketsEvent event, String data) {
if(event == WebsocketsEvent::ConnectionOpened) {
Serial.println("Connnection Opened");
} else if(event == WebsocketsEvent::ConnectionClosed) {
Serial.println("Connnection Closed");
} else if(event == WebsocketsEvent::GotPing) {
Serial.println("Got a Ping!");
} else if(event == WebsocketsEvent::GotPong) {
Serial.println("Got a Pong!");
}
}
void setup()
{
Serial.begin(115200);
wifiManager.autoConnect();
// Setup Callbacks
client.onMessage(onMessageCallback);
client.onEvent(onEventsCallback);
client.connect(SERVER);
client.send("Hello");
client.ping();
}
void loop()
{
client.send(String(millis()));
client.poll();
delay(500);
}
On my laptop, I can see an incoming connection:
$ sudo nc -l 80 -vvvv
Listening on [0.0.0.0] (family 0, port 80)
Connection from espressif 62507 received!
GET / HTTP/1.1
Host: 192.168.1.149
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: MDEyMzQ1Njc4OWFiY2RlZg==
Sec-WebSocket-Version: 13
But when I use websocat's server:
sudo websocat -s 80 -vvvv
Listening on ws://127.0.0.1:80/
[INFO websocat::lints] Auto-inserting the line mode
[DEBUG websocat] Done third phase of interpreting options.
[DEBUG websocat] Done fourth phase of interpreting options.
[DEBUG websocat] Preparation done. Now actually starting.
[INFO websocat::sessionserve] Serving Message2Line(WsServer(TcpListen(V4(127.0.0.1:80)))) to BroadcastReuser(Line2Message(Stdio)) with Options { websocket_text_mode: true, websocket_protocol: None, websocket_reply_protocol: None, udp_oneshot_mode: false, unidirectional: false, unidirectional_reverse: false, exit_on_eof: true, oneshot: false, unlink_unix_socket: false, exec_args: [], ws_c_uri: "ws://0.0.0.0/", linemode_strip_newlines: false, linemode_strict: false, origin: None, custom_headers: [], custom_reply_headers: [], websocket_version: None, websocket_dont_close: false, one_message: false, no_auto_linemode: false, buffer_size: 65536, broadcast_queue_len: 16, read_debt_handling: Warn, linemode_zero_terminated: false, restrict_uri: None, serve_static_files: [], exec_set_env: false, reuser_send_zero_msg_on_disconnect: false, process_zero_sighup: false, process_exit_sighup: false, socks_destination: None, auto_socks5: None, socks5_bind_script: None, tls_domain: None, tls_insecure: false, max_parallel_conns: None, ws_ping_interval: None, ws_ping_timeout: None }
The ESP32 will die:
*WM: [1] AutoConnect
*WM: [2] ESP32 event handler enabled
*WM: [2] Connecting as wifi client...
*WM: [1] STA static IP:
*WM: [2] setSTAConfig static ip not set
*WM: [3] WIFI station disconnect
*WM: [1] Connecting to saved AP: XXXXXXXX
*WM: [3] Using Password: XXXXXXXX
*WM: [3] WiFi station enable
*WM: [1] connectTimeout not set, ESP waitForConnectResult...
*WM: [2] Connection result: WL_CONNECTED
*WM: [3] lastconxresult: WL_CONNECTED
*WM: [1] AutoConnect: SUCCESS
*WM: [1] STA IP Address: 192.168.1.29
[E][WiFiClient.cpp:282] setOption(): fail on fd 54, errno: 22, "Invalid argument"
[E][WiFiClient.cpp:365] write(): fail on fd 54, errno: 104, "Connection reset by peer"
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4012d2c0 PS : 0x00060830 A0 : 0x8012d721 A1 : 0x3ffb1b90
A2 : 0x00000000 A3 : 0x3ffb1bef A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00000000 A7 : 0xffffffa7 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x3ffc8dcc A12 : 0x00000000 A13 : 0x00000001
A14 : 0x00060e20 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
Backtrace: 0x4012d2c0:0x3ffb1b90 0x4012d71e:0x3ffb1bb0 0x40173692:0x3ffb1be0 0x400dc65b:0x3ffb1c10 0x400dc2e6:0x3ffb1c30 0x400dcefa:0x3ffb1d70 0x400d20ad:0x3ffb1f60 0x400e0abf:0x3ffb1fb0 0x4008b015:0x3ffb1fd0
Rebooting...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
resolvedthe issue was resolvedthe issue was resolvedusage queshtionQueshtions about using the library, its interface and so onQueshtions about using the library, its interface and so on