fix: auto-repair origin not allowed in connect handshake + cleanup duplicate listeners

This commit is contained in:
晴天
2026-03-04 21:16:41 +08:00
parent 35143b52e4
commit ea251002c8
3 changed files with 9 additions and 4 deletions

View File

@@ -172,9 +172,9 @@ export class WsClient {
const errCode = msg.error?.code
console.error('[ws] connect 失败:', errMsg, errCode)
// 如果是配对错误,尝试自动配对
if (errCode === 'NOT_PAIRED' || errCode === 'PAIRING_REQUIRED') {
console.log('[ws] 检测到配对,尝试自动配对...')
// 如果是配对/origin 错误,尝试自动配对
if (errCode === 'NOT_PAIRED' || errCode === 'PAIRING_REQUIRED' || /origin not allowed/i.test(errMsg)) {
console.log('[ws] 检测到配对/origin 错误,尝试自动修复...', errCode || errMsg)
this._autoPairAndReconnect()
return
}