Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

根据响应超时时间进行重试 #239

Open
SuiYunsy opened this issue May 28, 2024 · 1 comment
Open

根据响应超时时间进行重试 #239

SuiYunsy opened this issue May 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@SuiYunsy
Copy link

SuiYunsy commented May 28, 2024

场景
在设置了重试次数的基础上,有时候某些渠道可能要等十几秒才能给出响应,然后才能根据响应决定是否重试。
解决方案
能否通过设置一个“响应超时时间”(比如10s),如果该渠道10s内没给出响应,就选择其他渠道进行重试?
songquanpeng/one-api#1059


另外还有一些疑惑:
目前看到config中有这两个设置项

  • relay_timeout: 0 # 中继请求超时时间,单位为秒,默认为 0。
  • connect_timeout: 5 # 连接超时时间,单位为秒,默认为 5。

但是实在是不懂“中继”和“连接”到底是什么意思,是否能实现上述的“响应超时时间”?望大佬解惑!

@SuiYunsy SuiYunsy added the enhancement New feature or request label May 28, 2024
@MartialBE
Copy link
Owner

connect_timeout 是 控制TCP 连接和WebSocket握手的超时时间。 如果超过5秒还链接不了服务器,则报错。
relay_timeout 是 控制 HTTP 请求的超时时间。 这个超时时间包括建立连接、发送请求、等待响应以及读取响应的全部过程。如果在指定的时间内无法完成这些操作,则报错。

你把relay_timeout设置为10,超时就会重试。 但是这个配置 会影响到其他地方的请求,比如 消息通知和图片上传。

不过有点问题, 会把渠道的请求地址暴露出来, 我要过滤一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants