升级至8069版本:版本号更新/代理配置系统/红包计时埋点/长连接重构/回调修复
This commit is contained in:
+19
-7
@@ -15,6 +15,7 @@ import (
|
||||
"xiawan/wx/clientsdk/mmtls"
|
||||
"xiawan/wx/db"
|
||||
"xiawan/wx/srv"
|
||||
"xiawan/wx/srv/srvconfig"
|
||||
"xiawan/wx/srv/websrv"
|
||||
"xiawan/wx/srv/wxface"
|
||||
)
|
||||
@@ -235,10 +236,9 @@ func (wxconn *WXConnect) StartShortReader() {
|
||||
return
|
||||
}
|
||||
forCount := 0
|
||||
// 最大重试次数
|
||||
const maxLongRetries = 5
|
||||
// 最小重试间隔 (秒)
|
||||
const minRetryInterval = 60
|
||||
// 从配置获取最大重试次数和重试间隔
|
||||
maxLongRetries := srvconfig.GlobalSetting.ProxyConfig.MaxLongRetryTimes
|
||||
minRetryInterval := int64(srvconfig.GlobalSetting.ProxyConfig.LongRetryInterval)
|
||||
|
||||
for {
|
||||
// 判断是否重复启动 for 循环
|
||||
@@ -311,8 +311,11 @@ func (wxconn *WXConnect) StartShortReader() {
|
||||
shouldRetry := (currentTime-wxconn.lastLongRetryTime >= minRetryInterval) &&
|
||||
(wxconn.longRetryCount < maxLongRetries)
|
||||
|
||||
// 如果重试计数器已达上限,但已经过去了更长时间(比如10分钟),重置计数器
|
||||
// 如果重试计数器已达上限,但已经过去了更长时间(比如10倍间隔),重置计数器
|
||||
if wxconn.longRetryCount >= maxLongRetries && (currentTime-wxconn.lastLongRetryTime >= minRetryInterval*10) {
|
||||
log.Printf("[%s],[%s] 重置长连接重试计数器(已过去足够长时间)\n",
|
||||
wxconn.GetWXAccount().GetUserInfo().GetUserName(),
|
||||
wxconn.GetWXAccount().GetUserInfo().NickName)
|
||||
wxconn.longRetryCount = 0
|
||||
shouldRetry = true
|
||||
}
|
||||
@@ -369,10 +372,11 @@ func (wxconn *WXConnect) StartShortReader() {
|
||||
} else if wxconn.longRetryCount >= maxLongRetries {
|
||||
// 只有在第一次达到最大重试次数时记录日志
|
||||
if wxconn.longRetryCount == maxLongRetries {
|
||||
log.Printf("[%s],[%s] 已达到最大重试次数(%d),暂停长连接恢复尝试\n",
|
||||
log.Printf("[%s],[%s] 已达到最大重试次数(%d),暂停长连接恢复尝试(将在%d秒后重置)\n",
|
||||
wxconn.GetWXAccount().GetUserInfo().GetUserName(),
|
||||
wxconn.GetWXAccount().GetUserInfo().NickName,
|
||||
maxLongRetries)
|
||||
maxLongRetries,
|
||||
minRetryInterval*10)
|
||||
wxconn.longRetryCount++ // 增加一次以避免重复打印
|
||||
}
|
||||
}
|
||||
@@ -597,6 +601,14 @@ func (wxconn *WXConnect) startLongLink() error {
|
||||
}
|
||||
tmpMMInfo.Dialer = dialer
|
||||
|
||||
// 设置代理配置到MMInfo
|
||||
tmpMMInfo.LongConnTimeout = srvconfig.GlobalSetting.ProxyConfig.LongConnTimeout
|
||||
tmpMMInfo.LongConnReadTimeout = srvconfig.GlobalSetting.ProxyConfig.LongConnReadTimeout
|
||||
tmpMMInfo.LongConnRetryTimes = srvconfig.GlobalSetting.ProxyConfig.LongConnRetryTimes
|
||||
tmpMMInfo.LongConnRetryInterval = srvconfig.GlobalSetting.ProxyConfig.LongConnRetryInterval
|
||||
tmpMMInfo.ShortConnTimeout = srvconfig.GlobalSetting.ProxyConfig.ShortConnTimeout
|
||||
tmpMMInfo.AllowDirectOnProxyFail = srvconfig.GlobalSetting.ProxyConfig.AllowDirectOnProxyFail
|
||||
|
||||
wxconn.setConnected(true)
|
||||
userInfo.MMInfo = tmpMMInfo
|
||||
// 启动长链接发送接收协程(创建新的定时器)
|
||||
|
||||
Reference in New Issue
Block a user