mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
feat: 增加sydney创建ws的重试机制,降低失败频率
This commit is contained in:
parent
88a97b6c92
commit
f5faa03d10
1 changed files with 11 additions and 2 deletions
|
|
@ -120,8 +120,17 @@ export default class SydneyAIClient {
|
||||||
if (this.opts.proxy) {
|
if (this.opts.proxy) {
|
||||||
agent = new HttpsProxyAgent(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('error', console.error)
|
||||||
|
|
||||||
ws.on('open', () => {
|
ws.on('open', () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue