GNOME Bugzilla – Bug 744209
rtspsrc: May stop sending keep alive due to buggy timeout in rtspconnection
Last modified: 2018-11-03 14:57:48 UTC
In 1.2.x, rtspsrc is sending out GET_PARAMETER every 75seconds, however , in 1.4.5/1.4.4, after the first GET_PARAMETER is sent out, there is no the second one. Tested on win7 and mac os x related post: http://gstreamer-devel.966125.n4.nabble.com/GStreamer-neither-keep-rtsp-alive-nor-re-connect-to-ip-camera-td4670632.html
This seems to work fine for me (in Linux anyway), it sends a GET_PARAMETER every 55 seconds, both in 1.4.4 and git master: RTSP request message 0x7f6395345ca0 request line: method: 'PLAY' uri: 'rtsp://127.0.0.1:8554/test/' version: '1.0' headers: key: 'Range', value: 'npt=0-' body: Progress: (request) Sending PLAY request RTSP response message 0x7f6395345d00 status line: code: '200' reason: 'OK' version: '1.0' headers: key: 'CSeq', value: '5' key: 'RTP-Info', value: 'url=rtsp://127.0.0.1:8554/test/stream=0;seq=8991;rtptime=2681263360' key: 'RTP-Info', value: 'url=rtsp://127.0.0.1:8554/test/stream=1;seq=11700;rtptime=2704522221' key: 'Range', value: 'npt=0-6575.574' key: 'Server', value: 'GStreamer RTSP server' key: 'Session', value: 'Pg5cn1lher+rVkXy' key: 'Date', value: 'Thu, 26 Mar 2015 12:43:06 GMT' body: length 0 Progress: (request) Sent PLAY request Redistribute latency... RTSP request message 0x7f6395345d30 request line: method: 'GET_PARAMETER' uri: 'rtsp://127.0.0.1:8554/test/' version: '1.0' headers: body: RTSP response message 0x7f6395345e00 status line: code: '200' reason: 'OK' version: '1.0' headers: key: 'CSeq', value: '6' key: 'Server', value: 'GStreamer RTSP server' key: 'Date', value: 'Thu, 26 Mar 2015 12:44:01 GMT' body: length 0 RTSP request message 0x7f6395345d30 request line: method: 'GET_PARAMETER' uri: 'rtsp://127.0.0.1:8554/test/' version: '1.0' headers: body: RTSP response message 0x7f6395345e00 status line: code: '200' reason: 'OK' version: '1.0' headers: key: 'CSeq', value: '7' key: 'Server', value: 'GStreamer RTSP server' key: 'Date', value: 'Thu, 26 Mar 2015 12:44:56 GMT' body: length 0 Could you provide a GST_DEBUG=*rtsp*:6 debug log?
Created attachment 300370 [details] [review] rtspconnection: Fix timeout handling When dealing with GTimeVal, if we have one but value is 0 0 we should timeout right way. In many places we would block forever instead. As an opposite, some other case would never block (using g_cond_wait_until() passing time now will return right way). This should fix rare case of RTSP keep-alive not being sent anymore.
Created attachment 300371 [details] [review] rtspsrc: Remove uneeded keep-alive hack The rtsp connection code has been fixed now.
This explain why keep alive may stop being sent in UDP, but does not explain why 1.2 was less likely to hit this issue then 1.4 though.
Comment on attachment 300370 [details] [review] rtspconnection: Fix timeout handling >+ /* Timeout period have expired already */ >+ if (to == 0) >+ return GST_RTSP_ETIMEOUT; >+ } >+ > g_socket_client_set_timeout (conn->client, > (to + GST_SECOND - 1) / GST_SECOND); Hrm, it's not clear to me that this is correct, if it should really not even attempt to read any data here. That would be a bit like changing gst_bus_timed_pop() to always return NULL if timeout is 0 even if there's a pending message, no?
Ok, let's be honest, the entire timeout API is broken here. Socket timeout is per operation, it won't help hitting a deadline.
Created attachment 300392 [details] [review] rtspconnection: Fix timeout handling When dealing with GTimeVal, if we have one but value is 0 0 we should timeout right way. In many places we would block forever instead. As an opposite, some other case would never block (using g_cond_wait_until() passing time now will return right way). This should fix rare case of RTSP keep-alive not being sent anymore.
Nicolas, what's the status of this? All broken beyond repair or is your latest patch fixing it? :)
It's a good question. I don't have a test to actually reproduce the issue, I only have an good understanding of why it will constantly stop working from reading the code. The design of the timeout is flawed to start with, but I would probably not say beyond repair. I think the patch should improve the situation slightly, but more testing is required. My general impression is that in the long term we should entirely deprecate these read/write method and implement proper async() GIO methods. GTask solves a lot of the issues we are facing now and would greatly improve scalability. Right now the code is doing very little multiplexing, and won't scale with a large group of connections.
Review of attachment 300392 [details] [review]: ::: gst-libs/gst/rtsp/gstrtspconnection.c @@ +802,3 @@ + } else { + GST_ERROR ("failed to connect: %s", error->message); + res = GST_RTSP_ETIMEOUT; Should probably be a generic error, not a timeout in that second case. @@ +912,3 @@ + } else { + GST_ERROR ("failed to connect: %s", error->message); + res = GST_RTSP_ETIMEOUT; Same here.
I'm having the similar problem when I connect to a RTSP Server with TLS. When I configure the RTSP Server to TCP only there's no problem with keep_alive. Gst Version 1.4.1 kernel 3.10.17 arch=armv7 (imx6) GST_DEBUG=3 log. gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtpmanager/rtpjitterbuffer.c:185:rtp_jitter_buffer_set_clock_rate: Clock rate changed from 0 to 90000 [ 322.203400] mxc_sdc_fb fb.20: MXCFB_WAIT_FOR_VSYNC: timeout 0 Jan 01 00:09:52 colibri-imx6 run_graphics.sh[523]: onRtpBinPadAdded: "video" linked Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.680961044 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:4364:gst_rtspsrc_send_keep_alive:<rtspsrc0> warning: Could not send keep-alive. (System error) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.681279377 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:4710:gst_rtspsrc_loop_udp:<rtspsrc0> warning: Unhandled return value -7. Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.681428377 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:4781:gst_rtspsrc_loop_udp:<rtspsrc0> error: Could not receive message. (System error) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.684107711 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:5067:gst_rtspsrc_loop:<rtspsrc0> error: Internal data flow error. Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.684153711 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:5067:gst_rtspsrc_loop:<rtspsrc0> error: streaming task paused, reason error (-5) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.725066711 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:5446:gst_rtspsrc_try_send:<rtspsrc0> error: Could not send message. (System error) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.725234377 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:7585:gst_rtspsrc_pause:<rtspsrc0> error: Could not send message. (System error) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.725411044 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:4710:gst_rtspsrc_loop_udp:<rtspsrc0> warning: Unhandled return value -7. Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.725553711 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:4781:gst_rtspsrc_loop_udp:<rtspsrc0> error: Could not receive message. (System error) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.725662044 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:5067:gst_rtspsrc_loop:<rtspsrc0> error: Internal data flow error. Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.725699044 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:5067:gst_rtspsrc_loop:<rtspsrc0> error: streaming task paused, reason error (-5) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.739512711 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:5446:gst_rtspsrc_try_send:<rtspsrc0> error: Could not send message. (System error) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: 0:06:05.740400711 525 0xfb4e30 WARN rtspsrc /home/caio/oe-core/build/out-glibc/work/armv7at2hf-vfp-neon-angstrom-linux-gnueabi/gstreamer1.0-plugins-good/1.4.1-r0/gst-plugins-good-1.4.1/gst/rtsp/gstrtspsrc.c:7057:gst_rtspsrc_close:<rtspsrc0> error: Could not send message. (System error) Jan 01 00:10:45 colibri-imx6 run_graphics.sh[523]: STATE NULL PIPELINE ERROR!!!
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/159.