8

I have a simple Rtsp Client...The client send Rtsp Commands to Rtsp Server and get RTP packets from server.

The problem is that after a time( about 3-4 minute) my 3rd party RTSP Server drop connection with my RTSP Client.

I have not implemented RTCP...I take rtp packets from rtsp server but does not send any RTCP PACKET...

I make simple search and find that some guys use some RTSP commands[ like OPTIONS, SET PARAMETER-GET PARAMETER ] too keep alive Connections between RTSP Server and Client... But in my case that does not work...

Here is my questions:

  1. What is the best way to keep alive connection with RTSP server?
  2. Do i have to implement RTCP [ send RTCP packets to server]? May the connection drop because i do not send RTCP packets to server?
Novalis
  • 2,265
  • 6
  • 39
  • 63

2 Answers2

8

What is the value of timeout you receive in SETUP response? Are you using this value for implementing keep alive functionality?

Session = "Session" ":" session-id [ ";" "timeout" "=" delta-seconds ]

Generally RTSP is based on TCP and RTP is based on UDP. So ideally both the channels require keep alive functionality. If RTP session is closed that does not mean that RTSP connection should also be teardown whereas RTP channels must be closed on RTSP channel teardown.

1) What is the best way to keep alive connection with RTSP server? --> Send any RTSP request periodically (OPTIONS, SET_PARAMETER or GET_PARAMETER) before timeout value received in SETUP response.

2) Do i have to implement RTCP [ send RTCP packets to server]? May the connection drop because i do not send RTCP packets to server? --> RFC (RTSP or RTP) does not mandate requirement of RTCP to keep RTP channels alive.

Alam
  • 1,536
  • 15
  • 26
  • My 3rd party rtsp server does not give session time out value...Although i send OPTIONS command at every 5 seconds it drops connection... – Novalis Oct 11 '11 at 12:55
  • It means your server is expecting RTCP packets. – Alam Oct 12 '11 at 03:46
  • Yes...When i send RTCP packets it does not drop connnections...But it "eats" an axtra bandwidth.. – Novalis Oct 12 '11 at 08:45
  • Cost of sending RTCP is minimal. RTCP should take only 5% of your total bandwidth. As you are concerned about bandwidth then sending RTCP is more important for you. Based on RTCP packets server can dynamically control bandwidth based on network load. RTCP can be used for calculating packet loss and jitter in the network. So RTCP is important for maintaining the quality of the system. – Alam Oct 13 '11 at 04:51
  • @Alam Sir i have the same case but problem is that my client connect to server through port 2222 and start receiving the rtsp stream from server now how will i send the RTSP request periodically (OPTIONS, SET_PARAMETER or GET_PARAMETER) before timeout value received in SETUP response on the same port while i will be receiving the stream data, – Dany Nov 19 '12 at 13:29
  • Your question is not very much clear to me... RTSP is a TCP connection. Use the same FD you used to connect with server on port 2222. RTP uses UDP which is different from RTSP channel. Keep alive message should be sent on RTSP channel not RTP channel – Alam Nov 29 '12 at 22:07
0

Sending an OPTIONS request didn't work for me.

The only RTSP command that I could send to keep the connection alive was GET_PARAMETER

My timeout is 60s and I send a GET_PARAMETER request every 40s

Works like a charm!

(No, you do not have to RTCP packets to the server)

kbotha
  • 11
  • 3
  • 1
    Note that "GET_PARAMETER" is not supported by all RTSP servers. Before sending it, you should check response to "OPTIONS" if it contains "GET_PARAMETER" parameter. – Gediminas Jul 28 '17 at 13:51