From f5a4f20e22a26c374da25c48f2652c32c7ec3b54 Mon Sep 17 00:00:00 2001 From: accius Date: Sat, 31 Jan 2026 23:41:37 -0500 Subject: [PATCH] Update server.js --- server.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index 8bc5d4a..7b2ece0 100644 --- a/server.js +++ b/server.js @@ -1812,12 +1812,19 @@ async function fetchITURHFPropPrediction(txLat, txLon, rxLat, rxLon, ssn, month, } try { - console.log('[Hybrid] Fetching from ITURHFProp service...'); + console.log('[Hybrid] Fetching from ITURHFProp service:', ITURHFPROP_URL); const url = `${ITURHFPROP_URL}/api/bands?txLat=${txLat}&txLon=${txLon}&rxLat=${rxLat}&rxLon=${rxLon}&ssn=${ssn}&month=${month}&hour=${hour}`; + console.log('[Hybrid] Request URL:', url); + + // Create abort controller for timeout + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 15000); // 15 second timeout + + const response = await fetch(url, { signal: controller.signal }); + clearTimeout(timeoutId); - const response = await fetch(url, { timeout: 10000 }); if (!response.ok) { - console.log('[Hybrid] ITURHFProp returned error:', response.status); + console.log('[Hybrid] ITURHFProp returned error:', response.status, response.statusText); return null; } @@ -1834,7 +1841,7 @@ async function fetchITURHFPropPrediction(txLat, txLon, rxLat, rxLon, ssn, month, return data; } catch (err) { - console.log('[Hybrid] ITURHFProp service unavailable:', err.message); + console.log('[Hybrid] ITURHFProp service error:', err.name, err.message); return null; } } @@ -2019,7 +2026,7 @@ app.get('/api/propagation', async (req, res) => { // Get ionospheric data at path midpoint const ionoData = interpolateFoF2(midLat, midLon, ionosondeStations); - const hasValidIonoData = ionoData && ionoData.method !== 'no-coverage' && ionoData.foF2; + const hasValidIonoData = !!(ionoData && ionoData.method !== 'no-coverage' && ionoData.foF2); const currentHour = new Date().getUTCHours(); const currentMonth = new Date().getMonth() + 1;