After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796797 - Gstreamer RTSP client connects to Gstreamer RTSP server: Only fixed number of connections are possible, then always "Error (503): Service Unavailable"
Gstreamer RTSP client connects to Gstreamer RTSP server: Only fixed number of...
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-rtsp-server
1.14.1
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-07-12 10:40 UTC by Marie Maurer
Modified: 2018-11-03 15:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Wireshark trace of 5 successful connection and 20 not successful connections (73.55 KB, application/octet-stream)
2018-07-12 10:40 UTC, Marie Maurer
Details
Gstreamer Log of the 25 connection, first 5 successfuly, other 20 not successful (451.31 KB, application/octet-stream)
2018-07-12 10:41 UTC, Marie Maurer
Details

Description Marie Maurer 2018-07-12 10:40:36 UTC
Created attachment 373004 [details]
Wireshark trace of 5 successful connection and 20 not successful connections

I have a Gstreamer RTSP server, Gstreamer version 1.14.1 on Linux i.MX6.
I use a Gstreamer RTSP client, Gstreamer version 1.14.1 also on Linux i.MX6.
Both on same machine or on different machines, does not matter.
Linux is almost mainline latest.

Client side:

# cat stopme_5s
eos,   name=Done-testing, playback-time=5.0
stop, playback-time=7.0

# cat run_streaming_5s_multiple_times.sh
echo "*************************************"
echo "*** HERE IS THE START OF THE TEST ***"
echo "*************************************"
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh
./run_streaming_5s.sh

# cat run_streaming_5s.sh
gst-validate-1.0 --set-scenario stopme_5s rtspsrc location=rtsp://10.5.121.255:8554/live ! capsfilter caps=application/x-rtp,media=video ! rtph264depay ! identity silent=false ! fakesink
#

Server side: 

Part of a bigger application. 

When I let run the above test script, I see that I can connect 5 times,
but all further connects are rejected by "Error (503): Service Unavailable".

Major problem: Why only 5 connections? TCP is completely disconnected,
no still established connections? Does RTSP server not handle sudden
disconnects of the TCP connections and requires TEARDOWN to work
correctly?

Minor problem: Is it correct, that Gstreamer RTSP client (Element rtspsrc)
does not use a TEARDOWN message? Instead just disconnects?

I found https://bugzilla.gnome.org/show_bug.cgi?id=757624, 
looks similar, but I assume that such an important bug is not existing for 3 years?

I attach a Wireshark trace and also a Gstreamer trace.
Comment 1 Marie Maurer 2018-07-12 10:41:49 UTC
Created attachment 373005 [details]
Gstreamer Log of the 25 connection, first 5 successfuly, other 20 not successful
Comment 2 Marie Maurer 2018-07-12 10:47:27 UTC
The "5" connections seem to come from:

/* set the max number of sessions */
GstRTSPSessionPool *sessionPool = gst_rtsp_server_get_session_pool(m_server);
gst_rtsp_session_pool_set_max_sessions(sessionPool, MAX_CLIENTS);
g_object_unref(sessionPool);

with MAX_CLIENTS set to 5.
Comment 3 Sebastian Dröge (slomo) 2018-07-12 11:28:36 UTC
Does it work if you set the required number there?
Comment 4 Marie Maurer 2018-07-12 11:39:16 UTC
I have set it to 5 and then 5 connections are possible.
I have not tried if I set number e.g. to 10, if 10 connections are possible.
All further connections are not possible.
No parallel connections! One after the other.

Where do I find variable, where open connections are counted?
Perhaps I can debug print the counter to see if it is increased
and decreased?
Comment 5 Sebastian Dröge (slomo) 2018-07-12 11:41:45 UTC
Without teardown, the server will still send the media data via UDP. It's valid to close the RTCP TCP connection, continue streaming, and later reconnect to send further commands.

The server will timeout the sessions based on RTCP though, if enabled.
Comment 6 Marie Maurer 2018-07-12 11:55:35 UTC
According your comment:
Many thanks for your explanation!
So a missing teardown is an error by Gstreamer RTSP client
or gst-validate-1.0 or of my script?
What does it mean "...timeout..., if enabled"?
Is there a function/property you have in mind?

I see "session pool reached max sessions of 5" 18 times in log.
It comes from 
gst1-rtsp-server-1.14.1/gst/rtsp-server/rtsp-session-pool.c
Variable for max number seems to be "max_sessions".

GstRTSPSession *
gst_rtsp_session_pool_create (GstRTSPSessionPool * pool)
{
...
    /* check session limit */
    if (priv->max_sessions > 0) {
      if (g_hash_table_size (priv->sessions) >= priv->max_sessions)
        goto too_many_sessions;
    }
...
}
Comment 7 Marie Maurer 2018-07-13 16:29:53 UTC
Is this the right way to go?
Taken e.g. from https://github.com/GStreamer/gst-rtsp-server/blob/master/examples/test-video.c

/* this timeout is periodically run to clean up the expired sessions from the
 * pool. This needs to be run explicitly currently but might be done
 * automatically as part of the mainloop. */
static gboolean
timeout (GstRTSPServer * server)
{
  GstRTSPSessionPool *pool;

  pool = gst_rtsp_server_get_session_pool (server);
  gst_rtsp_session_pool_cleanup (pool);
  g_object_unref (pool);

  return TRUE;
}

and calling it periodically 

/* add a timeout for the session cleanup */
  g_timeout_add_seconds (2, (GSourceFunc) timeout, server);

There is 

gst_rtsp_session_set_timeout (GstRTSPSession *session, guint timeout);

Is it also needed? Is the timeout only activated, when one is calling this function? What is default value, when this function is not called?
What is a good/minimum value for this timeout? Does a low value have disadvantages? E.g. a lot keep alive messages are exchanged?
(unfortunately the documentation is a bit less, not really describing
the important things. I refer to https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-rtsp-server/html/GstRTSPSession.html#gst-rtsp-session-set-timeout )
Comment 8 Marie Maurer 2018-07-18 09:39:06 UTC
Someone with knowledge? Is the above the right way to go?
Comment 9 GStreamer system administrator 2018-11-03 15:42:25 UTC
-- 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-rtsp-server/issues/45.