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

RTSP PROXY ISSUE #1105

Closed
2 of 13 tasks
Tabarane opened this issue Aug 19, 2022 · 9 comments
Closed
2 of 13 tasks

RTSP PROXY ISSUE #1105

Tabarane opened this issue Aug 19, 2022 · 9 comments
Labels
bug Something isn't working rtsp

Comments

@Tabarane
Copy link

Tabarane commented Aug 19, 2022

Which version are you using?

v0.20.0

Which operating system are you using?

  • Linux amd64 standard
  • Linux amd64 Docker
  • Linux arm64 standard
  • Linux arm64 Docker
  • Linux arm7 standard
  • Linux arm7 Docker
  • Linux arm6 standard
  • Linux arm6 Docker
  • Windows amd64 standard
  • Windows amd64 Docker (WSL backend)
  • macOS amd64 standard
  • macOS amd64 Docker
  • Other (please describe)

Describe the issue

I have camera which is sending some type of additional data and its cause the issue, idea is if im using FFMPEG to play it , it will give the below error

[rtsp @ 000001c44d179e80] Nonmatching transport in server reply rtsp://admin:admin1234@172.17.172.145:22101/1_88_1: Invalid data found when processing input

then i try to use Proxy with the help of RTSP server and it give me the error attached in server debug log

Config.yml

FFMPEG option

van:
   runOnDemand: ffmpeg -thread_queue_size 512 -i rtsp://admin:admin1234@172.17.172.145:22101/1_88_1 -vcodec libx264 -preset veryfast -r 24 -g 2 -s 1280x720 -b:v 3000k -max_muxing_queue_size 4096 -f rtsp rtsp://127.0.0.1:$RTSP_PORT/$RTSP_PATH
   runOnDemandRestart: yes
   sourceAnyPortEnable: yes

Proxy option

  Vanp:
   source: rtsp://admin:admin1234@172.17.172.145:22101/1_88_1
   sourceOnDemand: yes

Describe how to replicate the issue

  1. start server
  2. update config.yml
  3. request rtsp feed
  4. error appear

Did you attach the server logs?

yes / no

YES
server.log

Did you attach a network dump?

yes / no
NO

@aler9
Copy link
Member

aler9 commented Aug 27, 2022

Hello, please provide a network dump, that can be generated in this way:

  1. Download wireshark (https://www.wireshark.org/)
  2. Start capturing on the interface used for exchanging RTSP (if the server and the target software are both installed on your pc, the interface is probably "loopback", otherwise it's the one of your network card)
  3. Start the server and replicate the issue
  4. Stop capturing, save the result in .pcap format
  5. Attach

PS: when generating the network dump, use this configuration:

  Vanp:
   source: rtsp://admin:admin1234@172.17.172.145:22101/1_88_1
   sourceOnDemand: no

Start the server, wait 30seconds, stop the server, stop recording the dump and attach the dump.

@Tabarane
Copy link
Author

Tabarane commented Aug 27, 2022

Attached as requested per instructions
Vanp dump.zip
server ip is localhost , interface ip from windows machine is 10.10.101.109

loopback dump
Vanp dump 2 loopback.zip

ps: after like 3 or 4 attempt the feed worked but after trying again it kept failing as before

@aler9
Copy link
Member

aler9 commented Jan 18, 2023

Hello @Tabarane, thanks for providing the dumps, i finally found the issue. The server wants to pull the video stream from the camera with the UDP transport protocol:

[path Vanp] [rtsp source] c->s SETUP rtsp://172.17.172.145:22101/1_88_1/trackID=0 RTSP/1.0
Authorization: Digest username="admin", realm="Server", nonce="852167", uri="rtsp://172.17.172.145:22101/1_88_1/trackID=0", response="4ad478cdf926557eae6b82f0d4dbe90e"
CSeq: 4
Transport: RTP/AVP;unicast;client_port=65360-65361;mode=play
User-Agent: gortsplib

The camera accepts the request, but it replies with a response fit for the TCP transport protocol:

RTSP/1.0 200 OK
CSeq: 4
Session: WsDeuODg
Transport: RTP/AVP/TCP;unicast;source=172.17.172.145;server_port=22101;interleaved=0-1;ssrc=2A3B4C5D
X-Dynamic-Rate: 1

And subsequently starts sending the stream with the TCP transport protocol, causing this error:

[rtsp source] ERR: expected 'RTSP/1.0', got [36 0 0 27 128 96 0 0 0 0 17 148 42 59 76 93 103 66 0 41 141 141 64 90 30 208 15 8 132 83 128 36 0 0 16 128 96 0 1 0 0 17 148 42 59 76 93 104 202 67 200 36 0 5 120 128 96 0 2 0 0 17 148 42 59 76 93 124 133 136 128 0]

and this error in ffmpeg:

[rtsp @ 000001c44d179e80] Nonmatching transport in server reply rtsp://admin:admin1234@172.17.172.145:22101/1_88_1: Invalid data found when processing input

rtsp-simple-server and gortsplib need to be improved in order to detect TCP responses to UDP requests and switch protocol from UDP to TCP.

@aler9 aler9 added bug Something isn't working rtsp labels Jan 18, 2023
@Tabarane
Copy link
Author

@aler9 Thanks man, i hope im helping the project to improve , im using it since 2020 and its has been AMAZING, some challenges related to proxy type but not that BUG level yet )))

aler9 added a commit to bluenviron/gortsplib that referenced this issue Jan 18, 2023
(bluenviron/mediamtx#1105)

when a camera receives a UDP request and replies with a TCP responses,
switch protocol from UDP to TCP.
aler9 added a commit to bluenviron/gortsplib that referenced this issue Jan 18, 2023
(bluenviron/mediamtx#1105)

when a camera receives a UDP request and replies with a TCP responses,
switch protocol from UDP to TCP.
aler9 added a commit to bluenviron/gortsplib that referenced this issue Jan 18, 2023
(bluenviron/mediamtx#1105)

when a camera receives a UDP request and replies with a TCP responses,
switch protocol from UDP to TCP.
aler9 added a commit to bluenviron/gortsplib that referenced this issue Jan 18, 2023
(bluenviron/mediamtx#1105)

when a camera receives a UDP request and replies with a TCP responses,
switch protocol from UDP to TCP.
@aler9
Copy link
Member

aler9 commented Jan 18, 2023

@Tabarane
Copy link
Author

@aler9 Working like a charm in proxy mode , amazing man, still FFMPEG has raised error with non matching transport, but Proxy mode is like wow :)))
i have such type of issue when proxy with GARMIN VIRB 360 , if you interested i can gather logs for you , i always use very strange type of cameras and drones for my work and SRTSP is an Vital for me

aler9 added a commit to bluenviron/gortsplib that referenced this issue Jan 19, 2023
(bluenviron/mediamtx#1105)

when a camera receives a UDP request and replies with a TCP response,
switch protocol from UDP to TCP.
@aler9
Copy link
Member

aler9 commented Jan 19, 2023

If you have other problematic devices, feel free to open additional issues. Meanwhile, this is fixed.

@aler9
Copy link
Member

aler9 commented Jan 26, 2023

added in v0.21.2

@aler9 aler9 closed this as completed Jan 26, 2023
@github-actions
Copy link
Contributor

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.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working rtsp
Projects
None yet
Development

No branches or pull requests

2 participants