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

使用message http-timeout作为签名服务超时设置; 提供 1.1.6 版本以上 qsign 的对接支持 #2307

Merged
merged 17 commits into from
Aug 1, 2023

Conversation

1umine
Copy link
Contributor

@1umine 1umine commented Jul 20, 2023

Fix issue #2303

  • 可解决注册实例超时(通过修改配置块 messagehttp-timeout的值)
  • unidbg-fetch-qsign(1.1.x 版本)重启或其他原因导致实例丢失后,发消息时签名时会检测并尝试重新注册实例,避免需要重启gocq

更新内容

  • 增加自动注册实例配置项 auto-register,可自行决定是否在实例丢失时自动注册,默认为 false,推荐使用 qsign 的自动注册
  • 增加自动刷新token配置项 auto-refresh-token,可在 token 过期(丢失)时立即自动刷新 token,默认为 false
  • 增加配置项 token 定时刷新间隔时间 refresh-interval ,默认 40 分钟
  • 修复: 传递注册实例等需要的 android_id 参数修改为使用原始字符串(即device.json内的)而不是 hex.EncodeToString 转成的

其他

  • 可支持使用目前所有已发布的 qsign ( 应该,目前是到 1.1.7 为止),当然还是用新的最好(没有破坏性更新的话)
  • token 目前似乎无关紧要,可以更改配置项 auto-refresh-token以关闭丢失 token 时自动刷新,配置 refresh-interval 为 0 关闭定时刷新,丢失 token 暂时没有什么影响。
  • [2023-07-31] 使用最新 commit 编译的 go-cqhttp, 保持40分钟刷新一次,一个小时后签名返回的结果内 token 不再为空(本地编译的测试结果),不过测试期间(3h)签名返回的 token 没有更新,暂不知是机制如此还是提交的仍然不对的问题。 总之token不是空的了就好

@mmmjie
Copy link

mmmjie commented Jul 23, 2023

感谢,测试2个问题都解决了。

@1umine 1umine changed the title 使用message http-timeout作为签名服务超时设置 使用message http-timeout作为签名服务超时设置; 增加 auto-register 配置项; 增加 auto-refresh-token 配置项 Jul 26, 2023
@1umine 1umine changed the title 使用message http-timeout作为签名服务超时设置; 增加 auto-register 配置项; 增加 auto-refresh-token 配置项 使用message http-timeout作为签名服务超时设置; 增加 auto-register 和 auto-refresh-token 配置项; Jul 26, 2023
@1umine 1umine changed the title 使用message http-timeout作为签名服务超时设置; 增加 auto-register 和 auto-refresh-token 配置项; 使用message http-timeout作为签名服务超时设置; 增加 auto-register, auto-refresh-token, refresh-interval 配置项; Jul 27, 2023
@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

反复出现
[2023-07-28 18:28:12] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:28:12] [WARNING]: destroy 实例出现错误: Instance does not exist. server: https://127.0.0.1:47860/
然后签名器就崩了

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

签名器版本 https://github.com/fuqiuluo/unidbg-fetch-qsign/releases/tag/1.1.7
自己的 go-cqhttp 版本 https://github.com/YuChuXi/go-cqhttp ,在这个pr的基础上单独更改了注册实例时的超时为50s

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

有的时候会一次新重新注册三次
[2023-07-28 18:45:47] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:47] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:48] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册

@1umine
Copy link
Contributor Author

1umine commented Jul 28, 2023

有的时候会一次新重新注册三次
[2023-07-28 18:45:47] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:47] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:48] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册

应该是你发消息频率太快了,还没注册完后面又注册()

@1umine
Copy link
Contributor Author

1umine commented Jul 28, 2023

有的时候会一次新重新注册三次
[2023-07-28 18:45:47] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:47] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:48] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册

开启qsign的自动注册应该可以暂时解决一下

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

有的时候会一次重新重新注册三次
[2023-07-28 18:45:47] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:47] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:48] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册

开启qsign的自动注册应该可以暂时解决一下

开着,我觉得有可能还是超时了,我试试看

@1umine
Copy link
Contributor Author

1umine commented Jul 28, 2023

反复出现
[2023-07-28 18:28:12] [WARNING]: 获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:28:12] [WARNING]: destroy 实例出现错误: Instance does not exist. server: https://127.0.0.1:47860/ 然后签名器就崩了

要是签名服务器可用性高点这边应该写的应该也能轻松很多了 (可以随便造了)

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

我想过搞两个签名服务器
感觉不太实用

@1umine
Copy link
Contributor Author

1umine commented Jul 28, 2023

有的时候会一次重新重新注册三次
[2023-07-28 18:45:47] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:47] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:48] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册

开启qsign的自动注册应该可以暂时解决一下

开着,我觉得有可能还是超时了,我试试看

https://github.com/1umine/go-cqhttp/actions/runs/5692462867
可以试试,加了个互斥锁,简单自测了下可以用,实例销毁后快速发了3个消息时,只执行了一次注册

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

有的时候会一次重新重新注册三次
[2023-07-28 18:45:47] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:47] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册
[2023-07-28 18:45:48] [警告]:获取签名为空,实例可能丢失,正在尝试重新注册

开启qsign的自动注册应该可以暂时解决一下

开着,我觉得有可能还是超时了,我试试看

https://github.com/1umine/go-cqhttp/actions/runs/5692462867 可以试试,加了个互斥锁,简单自测了下可以用,实例销毁后快速发了3个消息时,只执行了一次注册

行,等会试试

@1umine
Copy link
Contributor Author

1umine commented Jul 28, 2023

我想过搞两个签名服务器 感觉不太实用

发消息的频率也控制一下吧,发太快可能自己没崩先被 tx 毙了()

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

我想过搞两个签名服务器 感觉不太实用

发消息的频率也控制一下吧,发太快可能自己没崩先被 tx 毙了()

偶尔这样(

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

我想过搞两个签名服务器 感觉不太实用

发消息的频率也控制一下吧,发太快可能自己没崩先被 tx 毙了()

我研究一下go-cq的令牌桶限速

@YuChuXi
Copy link

YuChuXi commented Jul 28, 2023

我知道了,获取签名签名器必崩

@Decrabbityyy
Copy link

可能需要sendpacket后才可以submit

@1umine
Copy link
Contributor Author

1umine commented Jul 28, 2023

可能需要sendpacket后才可以submit

主要就是不知道这一步要怎么做,不知道用gocq的哪个东西,看MiraiGo那边有个 uniPacket(command string, body []byte) 倒是挺像需要用的,但是导不了,fix-protocol-version 那边是调了个channel.sendMessage,没找到实现()

@KomeiDiSanXian
Copy link
Contributor

token的更新好像不是必须的?
似乎是每次sign请求会更新的
目前我挂了一个星期,每次控都是那种仅自己可见的。
如果实在是需要刷新token的话,考虑开一个协程定时更新?

@1umine
Copy link
Contributor Author

1umine commented Jul 29, 2023

token的更新好像不是必须的? 似乎是每次sign请求会更新的 目前我挂了一个星期,每次控都是那种仅自己可见的。 如果实在是需要刷新token的话,考虑开一个协程定时更新?

目前 token 看着好像确实是无关紧要,主要是一个小时候后 sign 返回的 token 会变成空的,不知道会有什么影响( 没准tx就会查这个 ),request 了 token 也没用,只能尽量适配 qsign 那边了。
定时更新已经加了 (虽然测试了下并没有什么作用,照样丢 token,give up 了

@1umine 1umine changed the title 使用message http-timeout作为签名服务超时设置; 增加 auto-register, auto-refresh-token, refresh-interval 配置项; 使用message http-timeout作为签名服务超时设置; 提供 1.1.6 版本以上 qsign 的对接支持 Jul 30, 2023
@fumiama fumiama merged commit f466ca7 into Mrs4s:dev Aug 1, 2023
0 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants