添加http错误提示
This commit is contained in:
19
play.lua
19
play.lua
@@ -213,7 +213,7 @@ local initTasks = {}
|
|||||||
for _, batch in ipairs(initBatches) do
|
for _, batch in ipairs(initBatches) do
|
||||||
table.insert(initTasks, function()
|
table.insert(initTasks, function()
|
||||||
while true do
|
while true do
|
||||||
local resp = http.post({
|
local resp,http_error = http.post({
|
||||||
url = server_url .. "/api/framepack?" .. batch.urls[1],
|
url = server_url .. "/api/framepack?" .. batch.urls[1],
|
||||||
headers = { ["Content-Type"] = "application/json" },
|
headers = { ["Content-Type"] = "application/json" },
|
||||||
body = textutils.serializeJSON({ urls = batch.urls }),
|
body = textutils.serializeJSON({ urls = batch.urls }),
|
||||||
@@ -231,10 +231,15 @@ for _, batch in ipairs(initBatches) do
|
|||||||
allFrameData[globalIdx] = batchFrames[idx]
|
allFrameData[globalIdx] = batchFrames[idx]
|
||||||
end
|
end
|
||||||
|
|
||||||
print("Cached init batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1))
|
print("[V] Cached init batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1))
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
print("Retry init batch starting at " .. batch.start)
|
print("[E] " .. batch.start .." "..http_error)
|
||||||
|
|
||||||
|
if http_error == "Response is too large" then
|
||||||
|
error("[E] Frame packet size exceeds 16MB. \nPlease try adjusting the screen size or resolution.")
|
||||||
|
end
|
||||||
|
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -345,7 +350,9 @@ local function httpResponseHandler()
|
|||||||
allFrameData[globalIdx] = batchFrames[idx]
|
allFrameData[globalIdx] = batchFrames[idx]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
print("[V] Cached batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1))
|
local sizeInMB = #binData / (1024 * 1024)
|
||||||
|
|
||||||
|
print("[V] Cached batch: " .. batch.start .. " - " .. (batch.start + #batchFrames - 1) .." ("..tonumber(string.format("%.1f", sizeInMB)).."Mb)")
|
||||||
else
|
else
|
||||||
print("[R] Unpack failed for batch " .. batch.start .. ": " .. tostring(batchFrames))
|
print("[R] Unpack failed for batch " .. batch.start .. ": " .. tostring(batchFrames))
|
||||||
-- 标记这些帧可重试
|
-- 标记这些帧可重试
|
||||||
@@ -361,7 +368,7 @@ local function httpResponseHandler()
|
|||||||
pendingRequests[url] = nil
|
pendingRequests[url] = nil
|
||||||
batch.retry = (batch.retry or 0) + 1
|
batch.retry = (batch.retry or 0) + 1
|
||||||
if batch.retry < 3 then
|
if batch.retry < 3 then
|
||||||
print("[R] Retrying batch " .. batch.start .. " (attempt " .. (batch.retry + 1) .. ")")
|
print("[R] Retrying batch " .. batch.start .. " (attempt " .. (batch.retry + 1) .. ") Error: "..handleOrErr)
|
||||||
-- 允许重试
|
-- 允许重试
|
||||||
for j = batch.start, batch.start + #batch.urls - 1 do
|
for j = batch.start, batch.start + #batch.urls - 1 do
|
||||||
downloadedFrames[j] = nil
|
downloadedFrames[j] = nil
|
||||||
@@ -369,6 +376,8 @@ local function httpResponseHandler()
|
|||||||
-- 重新触发 cacheAhead 下一轮会重发
|
-- 重新触发 cacheAhead 下一轮会重发
|
||||||
else
|
else
|
||||||
print("[X] Giving up on batch " .. batch.start)
|
print("[X] Giving up on batch " .. batch.start)
|
||||||
|
print("[E] " .. batch.start.." "..handleOrErr)
|
||||||
|
|
||||||
-- 永久失败,不再重试
|
-- 永久失败,不再重试
|
||||||
for j = batch.start, batch.start + #batch.urls - 1 do
|
for j = batch.start, batch.start + #batch.urls - 1 do
|
||||||
downloadedFrames[j] = true
|
downloadedFrames[j] = true
|
||||||
|
|||||||
Reference in New Issue
Block a user