bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.41k stars 1.45k forks source link

v0.23.0 drops with Reolink RLC-520A #1812

Closed blu006 closed 1 year ago

blu006 commented 1 year ago

Which version are you using?

v0.23.0

Which operating system are you using?

Describe the issue

v0.23.0 drops connection with the camera with the message [rtsp source] ERR: TCP timeout.

The previous version, v0.22.2 works as expected.

Describe how to replicate the issue

  1. start the server
  2. read the camera with RTSP

Did you attach the server logs?

no

Did you attach a network dump?

no

Future Server Log and Network Dumps

I can provide a side-by-side comparison complete with configuration files, logs, and network dumps in the near future

blu006 commented 1 year ago

Screenshot of information from the camera in question image

Tokolosh commented 1 year ago

exactly the same is happening with a hanwha techwin xnf-8010rv on rtsp

0ip commented 1 year ago

With v0.23.0, streaming from my RLC-520A (RTSP) via WebRTC/WHEP stops as well after about a minute. I'm receiving the same error message as @blu006. Another camera I own, a TP-Link Tapo C200, suffers the same fate, but occasionally there is an error message like ERR: EOF, or none at all.

aler9 commented 1 year ago

Until now no one provided any useful data that allows to replicate the issue, and without that it's impossible to identify the bug.

Please provide a network dump of communication exclusively between the server and the camera and a server log with log level set to debug.

Tokolosh commented 1 year ago

This is a debug log i was able to do on a testing machine with a local network camera - IP and Ports obfuscated with IP:PORT. with v22.2 everything is working fine mediamtx-v23-error.txt

aler9 commented 1 year ago

@Tokolosh there are no issues in the log you posted, with the exception of the warning "N RTP packets lost" that was added in v0.23.0 to warn about insufficient bandwidth but doesn't cause a stream to get dropped.

Tokolosh commented 1 year ago

@aler9 V22.2 works flawlessly and there are no bandwidth issues (during test only the test pc and a single ptz camera were on a seperate gigabit switch - camera feed is 16mbit) V23 always disconnects with the mentioned error (RTP packets lost) but V22.2 does not drop at all on the exact same setup. so something must have changed between versions

aler9 commented 1 year ago

@Tokolosh my aim is to find the error exactly as you, i just wanted to say that the error "RTP packets lost" is not an error but is a warning message that doesn't cause a stream to be dropped. It was added to to detect insufficient bandwidth. Errors that cause the stream to be dropped are the mentioned ERR: TCP timeout or ERR: EOF

aler9 commented 1 year ago

I checked the log of the underlying RTSP library (gortsplib) and the only major difference i could found between v0.23.0 and v0.22.2 is the one introduced with https://github.com/bluenviron/gortsplib/pull/265 . I reverted the change and compiled a nightly release, that is attached here. Please test it and let me know whether it solves the issue.

[link removed]

blu006 commented 1 year ago

Thanks for the nightly build! I tried with the nightly build that @aler9 made, and it still has the same issue with the same ERR: TCP timeout. Weird.

Anyway, I know I still need to provide a debug log along with a wireshark dump.

Tokolosh commented 1 year ago

Thanks for the nightly build! I tried with the nightly build that @aler9 made, and it still has the same issue with the same ERR: TCP timeout. Weird.

Anyway, I know I still need to provide a debug log along with a wireshark dump.

i'm getting the same as well. However i am also checking up on my connecting clients (restreamer/vlc/etc) to see if the problem could be on that end. I'll be back once i have more details.

Tokolosh commented 1 year ago

V23.1 seems stable with VLC (tested for 1 hour with no drops) - latest datarhei restreamer however is having issues (still testing things though)

mrgard commented 1 year ago

Fault seems to be that keep-alive to IP-camera is not being sent (e.g. missing GET_PARAMETER sent to IP-camera), and then after timeout the IP-camera will close the connection.

Compared old and new code in client.go in gortsplib, seems to be a new calculation method for timeout. Reinserted old calc method, recompiled, then it works fine!

//New calc method in v0.23 - fails:
//c.keepalivePeriod = time.Duration(((*sx.Timeout)*10)/8) * time.Second

//Old method used earlier - works:
c.keepalivePeriod = time.Duration(float64(*sx.Timeout)*0.8) * time.Second

Thanx @aler9 for a very good toolkit, keep up the good work!

aler9 commented 1 year ago

@mrgard thanks for debugging the issue, the point of that code was avoiding float64 computations after a user reported wrong results on ARM32 architectures, but I inverted numerator and denominator. I'll release a new version ASAP.

aler9 commented 1 year ago

fixed in v0.23.2.

0ip commented 1 year ago

Thank you @mrgard and @aler9

github-actions[bot] commented 9 months ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.