feat: 增加sydney创建ws的重试机制,降低失败频率

This commit is contained in:
ikechan8370 2023-03-07 23:21:22 +08:00
parent 88a97b6c92
commit f5faa03d10

View file

@ -120,8 +120,17 @@ export default class SydneyAIClient {
if (this.opts.proxy) {
agent = new HttpsProxyAgent(this.opts.proxy)
}
const ws = new WebSocket('wss://sydney.bing.com/sydney/ChatHub', { agent })
let retryTimes = 3
let ws
do {
try {
ws = new WebSocket('wss://sydney.bing.com/sydney/ChatHub', { agent })
break
} catch (err) {
logger.warn(err)
retryTimes--
}
} while (retryTimes > 0)
ws.on('error', console.error)
ws.on('open', () => {