Skip to content

PlayerEndpoint: rtspClientPortRange causes UDP port allocation failure when more than 20 concurrent instances are created #155

Description

@gferandelle-sr

Prerequisites

These are MANDATORY, otherwise the issue will be automatically closed.

Issue description

When specifying rtspClientPortRange in /etc/kurento/modules/kurento/PlayerEndpoint.conf.ini, every new PlayerEndpoint causes GStreamer to restart binding from the first port of the range. Since GStreamer is limited to 20 retries before failing, it is not possible to have more than 20 concurrent PlayerEndpoint instances.

0:23:59.607608579     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1303> Error binding to address 0.0.0.0:12000: Address already in use: error binding to 0.0.0.0:12000
0:23:59.607634911     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1303> error: bind failed: Error binding to address 0.0.0.0:12000: Address already in use
0:23:59.608006428     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1304> Error binding to address 0.0.0.0:12002: Address already in use: error binding to 0.0.0.0:12002
0:23:59.608107093     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1304> error: bind failed: Error binding to address 0.0.0.0:12002: Address already in use
0:23:59.608470981     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1305> Error binding to address 0.0.0.0:12004: Address already in use: error binding to 0.0.0.0:12004
0:23:59.608546345     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1305> error: bind failed: Error binding to address 0.0.0.0:12004: Address already in use
0:23:59.608868991     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1306> Error binding to address 0.0.0.0:12006: Address already in use: error binding to 0.0.0.0:12006
0:23:59.608882432     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1306> error: bind failed: Error binding to address 0.0.0.0:12006: Address already in use
0:23:59.609191069     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1307> Error binding to address 0.0.0.0:12008: Address already in use: error binding to 0.0.0.0:12008
0:23:59.609203750     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1307> error: bind failed: Error binding to address 0.0.0.0:12008: Address already in use
0:23:59.609504455     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1308> Error binding to address 0.0.0.0:12010: Address already in use: error binding to 0.0.0.0:12010
0:23:59.609515474     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1308> error: bind failed: Error binding to address 0.0.0.0:12010: Address already in use
0:23:59.609818039     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1309> Error binding to address 0.0.0.0:12012: Address already in use: error binding to 0.0.0.0:12012
0:23:59.609830351     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1309> error: bind failed: Error binding to address 0.0.0.0:12012: Address already in use
0:23:59.610149109     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1310> Error binding to address 0.0.0.0:12014: Address already in use: error binding to 0.0.0.0:12014
0:23:59.610162238     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1310> error: bind failed: Error binding to address 0.0.0.0:12014: Address already in use
0:23:59.610435615     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1311> Error binding to address 0.0.0.0:12016: Address already in use: error binding to 0.0.0.0:12016
0:23:59.610505450     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1311> error: bind failed: Error binding to address 0.0.0.0:12016: Address already in use
0:23:59.610816299     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1312> Error binding to address 0.0.0.0:12018: Address already in use: error binding to 0.0.0.0:12018
0:23:59.610828785     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1312> error: bind failed: Error binding to address 0.0.0.0:12018: Address already in use
0:23:59.611113810     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1313> Error binding to address 0.0.0.0:12020: Address already in use: error binding to 0.0.0.0:12020
0:23:59.611125629     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1313> error: bind failed: Error binding to address 0.0.0.0:12020: Address already in use
0:23:59.611397978     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1314> Error binding to address 0.0.0.0:12022: Address already in use: error binding to 0.0.0.0:12022
0:23:59.611409202     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1314> error: bind failed: Error binding to address 0.0.0.0:12022: Address already in use
0:23:59.611689853     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1315> Error binding to address 0.0.0.0:12024: Address already in use: error binding to 0.0.0.0:12024
0:23:59.611700570     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1315> error: bind failed: Error binding to address 0.0.0.0:12024: Address already in use
0:23:59.611969978     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1316> Error binding to address 0.0.0.0:12026: Address already in use: error binding to 0.0.0.0:12026
0:23:59.611981137     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1316> error: bind failed: Error binding to address 0.0.0.0:12026: Address already in use
0:23:59.612244426     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1317> Error binding to address 0.0.0.0:12028: Address already in use: error binding to 0.0.0.0:12028
0:23:59.612256214     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1317> error: bind failed: Error binding to address 0.0.0.0:12028: Address already in use
0:23:59.612526677     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1318> Error binding to address 0.0.0.0:12030: Address already in use: error binding to 0.0.0.0:12030
0:23:59.612538343     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1318> error: bind failed: Error binding to address 0.0.0.0:12030: Address already in use
0:23:59.612804317     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1319> Error binding to address 0.0.0.0:12032: Address already in use: error binding to 0.0.0.0:12032
0:23:59.612814973     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1319> error: bind failed: Error binding to address 0.0.0.0:12032: Address already in use
0:23:59.613082130     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1320> Error binding to address 0.0.0.0:12034: Address already in use: error binding to 0.0.0.0:12034
0:23:59.613093167     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1320> error: bind failed: Error binding to address 0.0.0.0:12034: Address already in use
0:23:59.613326117     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1321> Error binding to address 0.0.0.0:12036: Address already in use: error binding to 0.0.0.0:12036
0:23:59.613337416     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1321> error: bind failed: Error binding to address 0.0.0.0:12036: Address already in use
0:23:59.613528749     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1322> Error binding to address 0.0.0.0:12038: Address already in use: error binding to 0.0.0.0:12038
0:23:59.613538912     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1322> error: bind failed: Error binding to address 0.0.0.0:12038: Address already in use
0:23:59.613791596     1 0x7f0cf465dc10 ERROR                 udpsrc gstudpsrc.c:1636:gst_udpsrc_open:<udpsrc1323> Error binding to address 0.0.0.0:12040: Address already in use: error binding to 0.0.0.0:12040
0:23:59.613805025     1 0x7f0cf465dc10 WARN                  udpsrc gstudpsrc.c:1915:gst_udpsrc_open:<udpsrc1323> error: bind failed: Error binding to address 0.0.0.0:12040: Address already in use
0:23:59.613844365     1 0x7f0cf465dc10 ERROR                rtspsrc gstrtspsrc.c:7332:gst_rtspsrc_prepare_transports: failed to allocate udp ports

Context

We are running Kurento in an environment with around 80 cameras (not all displayed at the same time). UDP transport is required for low-latency video streaming. For cybersecurity purposes, we need to restrict port usage on our network. Setting rtspClientPortRange introduced this issue, which did not occur before because GStreamer was previously picking ports randomly via kernel allocation, naturally avoiding collisions between instances.

How to reproduce?

  1. Set rtspClientPortRange=<min-max> in /etc/kurento/modules/kurento/PlayerEndpoint.conf.ini
  2. Create more than 20 concurrent PlayerEndpoint instances pointing to RTSP sources
  3. Observe that rtspsrc fails to allocate UDP ports for instances created after the first ~20, with error failed to allocate udp ports

Expected & current behavior

Expected: All ports in the configured range are used without failure, regardless of the number of concurrent PlayerEndpoint instances.

Current: UDP port allocation fails because every new PlayerEndpoint restarts from the first port within the range and GStreamer exhausts its 20 retries before reaching any free port.

(Optional) Possible solution

The fix should be implemented in PlayerEndpointImpl.cpp. Currently, every PlayerEndpoint passes the full configured range to GStreamer, causing each underlying rtspsrc to always start binding from client_port_range.min:

Solutions could be to maintain counter tracking the last allocated port. Each new instance starts from where the previous one left or randomize the starting port within the configured range.

Info about your environment

  • ~80 IP cameras connected via PlayerEndpoint (RTSP sources)
  • UDP transport required (low-latency constraint)
  • WebRTC endpoints
  • Firewall between cameras and Kurento server, requiring strict port range control

About Kurento Media Server

  • Kurento version: 7.2.0
  • Server OS: Ubuntu 24.04
  • Installation method:

About your Application Server

  • Programming Language: Java
  • Kurento Client version: 7.2.0

About end-user clients

  • Device(s): Computer
  • OS(es): Ubuntu 22.04
  • Browser(s): Chrome

Run these commands

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.1 LTS"
kurento-media-server --version
Kurento Media Server version: 7.2.0
Found modules:
	'chroma' version 7.2.0
	'core' version 7.2.0
	'datachannelexample' version 7.2.0
	'elements' version 7.2.0
	'filters' version 7.2.0
dpkg -l | grep -Pi 'kurento|kms-|gst.*1.5|nice'
ii  gstreamer1.0-nice:amd64                0.1.21-2build3                       amd64        ICE library (GStreamer plugin)
ii  gstreamer1.0-nice-dbgsym:amd64         0.1.21-2build3                       amd64        debug symbols for gstreamer1.0-nice
ii  kurento-dbg                            7.2.0-1kurento1                      amd64        Meta-package that installs debug symbols
ii  kurento-jsonrpc                        7.2.0-1kurento1                      amd64        Kurento JSON-RPC library
ii  kurento-jsonrpc-dbgsym                 7.2.0-1kurento1                      amd64        debug symbols for kurento-jsonrpc
ii  kurento-media-server                   7.2.0-1kurento1                      amd64        Kurento Media Server
ii  kurento-media-server-dbgsym            7.2.0-1kurento1                      amd64        debug symbols for kurento-media-server
ii  kurento-module-chroma                  7.2.0-1kurento1                      amd64        Kurento Chroma filter
ii  kurento-module-core                    7.2.0-1kurento1                      amd64        Core module for use by Kurento Media Server
ii  kurento-module-core-dbgsym             7.2.0-1kurento1                      amd64        debug symbols for kurento-module-core
ii  kurento-module-datachannelexample      7.2.0-1kurento1                      amd64        Kurento WebRTC DataChannel example
ii  kurento-module-elements                7.2.0-1kurento1                      amd64        Kurento Elements module
ii  kurento-module-elements-dbgsym         7.2.0-1kurento1                      amd64        debug symbols for kurento-module-elements
ii  kurento-module-filters                 7.2.0-1kurento1                      amd64        Kurento Filters module
ii  kurento-module-filters-dbgsym          7.2.0-1kurento1                      amd64        debug symbols for kurento-module-filters
ii  libnice10:amd64                        0.1.21-2build3                       amd64        ICE library (shared library)
ii  libnice10-dbgsym:amd64                 0.1.21-2build3                       amd64        debug symbols for libnice10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions