mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-07-21 09:03:02 +02:00
fix(perf): polling-only Socket.IO + channels DB fallback on USB timeout
Werkzeug dev server can't upgrade WebSockets, so every io() upgrade attempt returned HTTP 500 and clients fell into a polling/upgrade reconnect loop — visible as 10-15s freezes on app load. Force transports: ['polling'] on /chat, /console and /logs clients; long-poll keeps real-time pushes working with ~1-2s latency. When the MeshCore device briefly stalls, get_channel_info() used to block on the default 30s timeout per slot, so iterating max_channels slots could take minutes; in practice only Public answered and the rest timed out, leaving the UI with just one channel. Drop per-call timeout to 3s, raise TimeoutError to the caller, and have cli.get_channels() break on first timeout and merge the remaining slots from the channels table in the DB (which already mirrors device state via upsert_channel). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -403,7 +403,8 @@ function connectChatSocket() {
|
||||
|
||||
const wsUrl = window.location.origin;
|
||||
chatSocket = io(wsUrl + '/chat', {
|
||||
transports: ['websocket', 'polling'],
|
||||
transports: ['polling'],
|
||||
upgrade: false,
|
||||
reconnection: true,
|
||||
reconnectionDelay: 2000,
|
||||
reconnectionDelayMax: 10000,
|
||||
|
||||
@@ -38,7 +38,8 @@ function connectWebSocket() {
|
||||
|
||||
try {
|
||||
socket = io(wsUrl + '/console', {
|
||||
transports: ['websocket', 'polling'],
|
||||
transports: ['polling'],
|
||||
upgrade: false,
|
||||
reconnection: true,
|
||||
reconnectionAttempts: Infinity,
|
||||
reconnectionDelay: 1000,
|
||||
|
||||
+2
-1
@@ -125,7 +125,8 @@ function connectChatSocket() {
|
||||
|
||||
const wsUrl = window.location.origin;
|
||||
chatSocket = io(wsUrl + '/chat', {
|
||||
transports: ['websocket', 'polling'],
|
||||
transports: ['polling'],
|
||||
upgrade: false,
|
||||
reconnection: true,
|
||||
reconnectionDelay: 2000,
|
||||
reconnectionDelayMax: 10000,
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
|
||||
// --- WebSocket ---
|
||||
const socket = io('/logs', {
|
||||
transports: ['websocket', 'polling'],
|
||||
transports: ['polling'],
|
||||
upgrade: false,
|
||||
reconnection: true,
|
||||
reconnectionDelay: 2000,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user