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
+1 -1
View File
@@ -1137,7 +1137,7 @@
</main>
</div>
<script src="/custom-dialog.js?v=11"></script>
<script src="index.js?v=6"></script>
<script src="index.js?v=7"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const isDomain = location.hostname.includes('fse-media.group');
+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([]);
+1 -1
View File
@@ -593,7 +593,7 @@
</div>
<script src="/custom-dialog.js?v=11"></script>
<script src="/public-status.js?v=14"></script>
<script src="ticket-route.js?v=7"></script>
<script src="ticket-route.js?v=8"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const isDomain = location.hostname.includes('fse-media.group');
+2 -2
View File
@@ -23,8 +23,8 @@ createApp({
});
const connected = ref(false);
// Keep the legacy route console usable behind proxies that only allow polling.
const socket = io({ transports: ['polling', 'websocket'], timeout: 20000 });
// 强制使用 WebSocket,避免轮询 (polling) 在负载均衡/反代下产生 400 Bad Request
const socket = io({ transports: ['websocket'], timeout: 20000 });
const stations = ref([]);