Open cpatulea opened 2 hours ago
It does seem like it's Chrome which decides to close the connection:
Hmm, might be the preflight OPTIONS requests, which the ESP32 responds with 404 and 'Connection: close':
OPTIONS /api/v1/fromradio?all=false HTTP/1.1 Accept-Encoding: gzip, deflate, br, zstd Accept-Language: en-US,en;q=0.9 Access-Control-Request-Method: GET Access-Control-Request-Private-Network: true Connection: keep-alive Host: 192.168.0.190 Origin: https://client.meshtastic.org Referer: https://client.meshtastic.org/ Sec-Fetch-Dest: empty Sec-Fetch-Mode: cors Sec-Fetch-Site: cross-site User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
HTTP/1.1 404 Not Found Connection: close Content-Type: text/plain;charset=utf8
Code link for 404 showing explicit 'Connection: close': https://github.com/meshtastic/esp32_https_server/blob/896f1771ceb5979987a0b41028bf1b4e7aad419b/src/HTTPConnection.cpp#L277
Recent CORS policy issue, not sure if related: https://github.com/meshtastic/web/issues/249
/api/v1/fromradio doesn't seem to have a OPTIONS handler?
Serial log during this:
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 35 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 35 [WebServer] FromRadio=STATE_SEND_MY_INFO
DEBUG | ??:??:?? 35 [WebServer] webAPI handleAPIv1FromRadio, len 25
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 37 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 37 [WebServer] Send My NodeInfo
DEBUG | ??:??:?? 37 [WebServer] webAPI handleAPIv1FromRadio, len 92
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 38 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 38 [WebServer] Send device metadata
DEBUG | ??:??:?? 38 [WebServer] webAPI handleAPIv1FromRadio, len 37
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 40 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 40 [WebServer] webAPI handleAPIv1FromRadio, len 13
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 42 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 42 [WebServer] webAPI handleAPIv1FromRadio, len 6
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
DEBUG | ??:??:?? 43 [WebServer] webAPI handleAPIv1FromRadio
DEBUG | ??:??:?? 43 [WebServer] webAPI handleAPIv1FromRadio, len 6
[HTTPS:I] Request: OPTIONS /api/v1/fromradio?all=false (FID=53)
[HTTPS:W] Could not find a matching resource
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:E] SSL_accept failed. Aborting handshake. FID=53
[HTTPS:I] Connection closed. Socket FID=53
[HTTPS:I] New connection. Socket FID=53
[HTTPS:I] Request: GET /api/v1/fromradio?all=false (FID=53)
Category
WiFi
Hardware
Heltec V3
Firmware Version
2.5.11.8e2a3e5
Description
Chrome (~90 seconds):
https://github.com/user-attachments/assets/6945fdc0-bc10-4005-93c8-74faf714507e
Firefox (~4 seconds):
https://github.com/user-attachments/assets/60737f5f-e9b8-48ba-b4e9-88adb8af74ee
I think this is because Chrome re-establishes the connection (TCP+TLS) for each request:
Connection keep-alive is supposed to work, and make a huge difference, as seen in Firefox, where each request takes only ~60 ms.
I thought I figured out the reason Chrome connections don't keep alive but I found some conflicting clues so now I'm not so sure I understand why.
Relevant log output
No response