HTTPS WebSocket reconnect loop on ESP32 (Wizard 1.0.3 / Mongoose 7.22 / ESP-IDF 5.5.4) #3640
Replies: 1 comment
|
Hello, this is the Mongoose library repository. Here we develop the code for the Mongoose library, Wizard usage issues or questions do not belong here. PS: The issue template is there to save yours and our time. Please fill it as requested, do not post huge chunks of TL;DR AI-generated comments that only add noise and steer the focus, Thank you again. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I'm developing an ESP32 application using a project generated by Mongoose Wizard.
Environment
The Web UI is generated by Mongoose Wizard.
I have not modified the generated WebSocket implementation.
The project only uses the standard Wizard websocket reporters.
Problem
Everything works correctly over HTTP.
As soon as I enable the HTTPS listener, WebSocket connections start reconnecting continuously.
What works
✓ HTTP page
✓ HTTPS page
✓ Login
✓ Authentication
✓ Cookie authentication
✓ HTTP REST API
✓ WebSocket handshake (HTTP 101 Switching Protocols)
What does not work
The WebSocket connection stays alive for approximately one second and then closes.
The browser immediately opens a new WebSocket connection.
This repeats forever.
Chrome Network shows:
websocket 101
websocket 101
websocket 101
websocket 101
...
Each connection lasts approximately one second.
Browser observations
Chrome Network:
Browser console:
connection to wss:///websocket was interrupted
Some reconnect attempts also produce:
Failed to load resource:
net::ERR_CONNECTION_RESET
UART logs
A successful connection looks like this:
GET /websocket 101
followed by websocket traffic.
Then:
mg_ws_cb WS CLOSE
followed by:
mg_close_conn closed
Immediately afterwards the browser opens a new HTTPS connection.
Some reconnect attempts fail during the TLS handshake:
TLS ALERT received:
level=2
desc=46 (certificate_unknown)
TLS Fatal alert
The next reconnect usually succeeds and again reaches:
GET /websocket 101
HTTP vs HTTPS
If I completely disable the HTTPS listener:
HTTP + WebSocket works correctly and remains connected.
As soon as I enable the HTTPS listener:
HTTP listener
All reactions