fix: SimNow 登录封禁(错误75)时冷却退避,停止自动重连
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+17
-2
@@ -20,6 +20,7 @@
|
||||
var priceType = 'limit';
|
||||
var lastCtpReconnectAt = 0;
|
||||
var lastCtpUnreachableAt = 0;
|
||||
var lastCtpLoginBanAt = 0;
|
||||
var ctpReconnecting = false;
|
||||
var ctpConnectInflight = false;
|
||||
var isTradingSession = false;
|
||||
@@ -128,6 +129,15 @@
|
||||
if (hint) hint.textContent = msg || '';
|
||||
}
|
||||
|
||||
function isCtpLoginBanError(msg) {
|
||||
return !!(msg && (
|
||||
msg.indexOf('登录被禁止') >= 0 ||
|
||||
msg.indexOf('连续登录失败') >= 0 ||
|
||||
msg.indexOf('登录冷却') >= 0 ||
|
||||
msg.indexOf('错误码 75') >= 0
|
||||
));
|
||||
}
|
||||
|
||||
function isCtpUnreachableError(msg) {
|
||||
return !!(msg && (msg.indexOf('不可达') >= 0 || msg.indexOf('Connection refused') >= 0 || msg.indexOf('timed out') >= 0));
|
||||
}
|
||||
@@ -143,7 +153,9 @@
|
||||
updateCtpBadge(!!connected, !!connecting);
|
||||
if (!connected && !connecting && data.ctp_status && data.ctp_status.last_error) {
|
||||
showCtpError(data.ctp_status.last_error);
|
||||
if (isCtpUnreachableError(data.ctp_status.last_error)) {
|
||||
if (isCtpLoginBanError(data.ctp_status.last_error)) {
|
||||
lastCtpLoginBanAt = Date.now();
|
||||
} else if (isCtpUnreachableError(data.ctp_status.last_error)) {
|
||||
lastCtpUnreachableAt = Date.now();
|
||||
}
|
||||
}
|
||||
@@ -342,7 +354,9 @@
|
||||
updateCtpBadge(false, false);
|
||||
if (st.last_error) {
|
||||
showCtpError(st.last_error);
|
||||
if (isCtpUnreachableError(st.last_error)) {
|
||||
if (isCtpLoginBanError(st.last_error)) {
|
||||
lastCtpLoginBanAt = Date.now();
|
||||
} else if (isCtpUnreachableError(st.last_error)) {
|
||||
lastCtpUnreachableAt = Date.now();
|
||||
}
|
||||
}
|
||||
@@ -497,6 +511,7 @@
|
||||
if (ctpReconnecting || ctpConnectInflight) return;
|
||||
var now = Date.now();
|
||||
if (now - lastCtpReconnectAt < 60000) return;
|
||||
if (lastCtpLoginBanAt && now - lastCtpLoginBanAt < 2700000) return;
|
||||
if (lastCtpUnreachableAt && now - lastCtpUnreachableAt < 300000) return;
|
||||
lastCtpReconnectAt = now;
|
||||
ctpReconnecting = true;
|
||||
|
||||
Reference in New Issue
Block a user