Refactor Mihomo traffic and memory handling to use streaming GET requests
Publish telemt-api gateway Docker image / test (push) Successful in 27s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 2m6s

- Updated `GATEWAY_RUN.md` to clarify the use of streaming HTTP GET for traffic and memory metrics instead of WebSocket connections, addressing potential issues with WebSocket stability behind nginx.
- Modified the Svelte component to implement streaming GET requests for `/traffic` and `/memory`, improving data retrieval and reducing connection issues.
- Enhanced the `recordRates` function to handle totals from the streaming response, ensuring accurate metric tracking.
This commit is contained in:
Denozordec
2026-03-31 01:26:02 +07:00
parent b1839c5ebe
commit 50fe3df7e6
3 changed files with 106 additions and 40 deletions
+4 -1
View File
@@ -20,7 +20,10 @@ export function mihomoUrl(alias: string, path: string): string {
return `${gatewayBase()}/api/${encodeURIComponent(alias)}/mihomo/${p}`;
}
/** WebSocket к тому же origin (ws / wss). */
/**
* WebSocket к тому же origin (ws / wss).
* Для /traffic и /memory во фронте предпочтительнее потоковый GET через `mihomoUrl` — тот же прокси, что и для REST; WS из браузера часто рвётся за nginx.
*/
export function mihomoWsUrl(alias: string, path: string): string {
const p = path.replace(/^\/+/, '');
const base = gatewayBase();