Parcourir la source

修复MJPEG长连接断流导致手机视频加载失败

- 根因: httplib默认keep-alive=5秒, MJPEG长连接5秒后断开
- set_keep_alive_max_count(0)会触发处理循环直接退出(HTTP 000)
- 改为 max_count=1000, timeout=3600
- 实测: keep-alive 3600s, MJPEG 8秒77帧持续稳定
dev il y a 6 jours
Parent
commit
35850e4b01
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 3 0
      src/web_server.cpp

+ 3 - 0
src/web_server.cpp

@@ -78,6 +78,9 @@ public:
     }
 
     void setupRoutes() {
+        // MJPEG长连接: keep-alive默认5秒会断开推流, 设为1小时
+        svr.set_keep_alive_max_count(1000);   // 复用上限
+        svr.set_keep_alive_timeout(3600);     // 1小时
         svr.Get("/", [this](const httplib::Request& req, httplib::Response& res) {
             if (hooks_set_ && !authed(req)) {
                 res.status = 302;