fix(web): 强制 Socket.IO 使用 WebSocket 传输

因为线上环境没有配置 IP Hash (Sticky Sessions),导致默认的 polling 长轮询请求会随机分配到不同后端,从而引发 400 Bad Request 和连接断开重连刷屏的问题。
现将 transports 锁定为 ['websocket'],直接使用 WebSocket 连接。
This commit is contained in:
2026-08-08 10:42:00 +08:00
parent 3d38e16917
commit 41546cce96
4 changed files with 6 additions and 7 deletions
+2 -3
View File
@@ -35,9 +35,8 @@ createApp({
return map[currentView.value] || '票价图';
});
// Prefer polling first so admin remains connected even when the proxy
// does not support WebSocket upgrades reliably.
const socket = io({ transports: ['polling', 'websocket'] });
// 强制使用 WebSocket,避免轮询 (polling) 在负载均衡/反代下产生 400 Bad Request
const socket = io({ transports: ['websocket'], timeout: 20000 });
// Data State
const stations = ref([]);