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

RTMP 推送设备断电后,超时逻辑未能正确执行 #67

Closed
ningnao opened this issue Oct 26, 2023 · 4 comments · Fixed by #68
Closed

RTMP 推送设备断电后,超时逻辑未能正确执行 #67

ningnao opened this issue Oct 26, 2023 · 4 comments · Fixed by #68
Labels
bug Something isn't working

Comments

@ningnao
Copy link
Contributor

ningnao commented Oct 26, 2023

XIU version
master(65c8def)

Describe the bug
RTMP 推送设备断电后,超时逻辑未能正确执行

排查了一下原因,设备断电后程序阻塞在了这行代码

// library/bytesio/src/bytesio.rs:159
158  async fn read(&mut self) -> Result<BytesMut, BytesIOError> {
159          let message = self.stream.next().await;  <- 阻塞在这行代码
160  
161          match message {
162              Some(data) => match data {
...

因此在read_timeout()方法中的超时逻辑未能正确执行,当设备恢复重连的时候,旧链接未被关闭,出现以下错误

2023-10-26T02:40:36Z ERROR streamhub] event_loop Publish err: exists

另外在read_timeout()方法中处理超时逻辑会将read()方法中的异常信息覆盖掉,这在排查问题的过程中造成了一定的困扰

ningnao added a commit to ningnao/xiu that referenced this issue Oct 26, 2023
@ningnao
Copy link
Contributor Author

ningnao commented Oct 26, 2023

我尝试对这个问题进行修复并提交了PR,不知道这样处理是否妥当

@harlanc
Copy link
Owner

harlanc commented Oct 27, 2023

这个函数之前改过一版,commit,记不太清楚问题是如何复现的了,但看来还是有问题的,我这边也再好好测测。

@ningnao
Copy link
Contributor Author

ningnao commented Oct 27, 2023

我看了这版代码,read_timeout方法中对超时的处理似乎没有问题,但在read_parse_chunks方法中实际调用的read方法,并没有调用read_timeout,我想这应该是出现问题的原因

@harlanc
Copy link
Owner

harlanc commented Oct 27, 2023

嗯嗯,有可能,测试了两种case,这里也记录一下:

  1. ffmpeg 推RTMP流到xiu,非正常退出(kill杀死进程)
  2. OBS推流(MAC),非正常退出(Mac的强制退出)

self.stream.next().await 这句话没有pending,而是直接返回了None

harlanc added a commit that referenced this issue Oct 27, 2023
@harlanc harlanc added the bug Something isn't working label Oct 27, 2023
@harlanc harlanc linked a pull request Oct 27, 2023 that will close this issue
@harlanc harlanc closed this as completed Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants