streaming plugin, passing "0" as the port used to be random, now always getting the same port?

116 views
Skip to first unread message

Kaplan

unread,
Mar 22, 2020, 5:41:34 AM3/22/20
to meetecho-janus
Hi Janusers,
I am RTP forwarding from an audio room (or video room) to a streaming plugin endpoint created like this 
 {
                            "request": "create",
                            "secret": self.janusAdminSectret,
                            "type": 'rtp',
                            "id": parseInt(self.audioRoomID),
                            "is_private": true,
                            "audio": true,
                            "video": false,
                            "audioport": 0, //passing 0 gets a free random port
                            "audiopt": 96,
                            "audiortpmap": 'OPUS/48000/2'
     }

I am sometimes always getting the same "random" port back. say 10000.  (and of course the port is being used by a previous mount-point) and I get the infamous
[mp-1012] New audio stream! (ssrc=3487809223) over and over again...

this is on a fresh 0.9.1 version f Janus, but I saw it happening on 0.7.3 as well.

Kaplan

unread,
Mar 22, 2020, 5:57:50 AM3/22/20
to meetecho-janus
I think whats happening is that the RTP forwarders , even though  I destroy the audio room, are still there? I believe the RTP forwarders used to get destroyed if the audio room gets destroyed.

Kaplan

unread,
Mar 22, 2020, 6:10:21 AM3/22/20
to meetecho-janus
Actually, I just verified and the RTP forwarders do get destroyed.  But on the newer Januses, I seem to always get the same random port (say 10000), even after destroying the streaming endpoint and creating a new one (with the same name), I seem to always get the same port, which causes isues. I saw an old bug: https://github.com/meetecho/janus-gateway/issues/1178#
On older version if janus, I do get a truly random port with each call to "create" on the streaming plugin...

Kaplan

unread,
Mar 22, 2020, 7:02:59 AM3/22/20
to meetecho-janus
Also wanted to mention this is a clean  Debian Buster install, may be its a Debian 10 thingy?? all other Januses run in Debian 9

Lorenzo Miniero

unread,
Mar 23, 2020, 5:59:30 AM3/23/20
to meetecho-janus
A few months ago we changed (thanks to a contribution) the way we allocate "random" ports, in order to use a port range and a custom slider:

By default, the range starts at 10000 when you don't override it. Works as expected here, for me: if I create two mountpoints in a row, one will use 10000 and the other 10001. If the 10000 mountpoint is removed, that port becomes available again for subsequent create requests.

L.

Kaplan

unread,
Mar 23, 2020, 7:33:33 AM3/23/20
to meetecho-janus
thanks for the info!. yes, I keep getting the same 10000 "random" port after I tear down the mount-point, and re-create it, but there is "something" sending data there (not something of mine) , so I get the new source over and over message, and audio is choppy..
so if I comfigure a range, say from 5000-65000, if I pass "0" as the port, will I always get the first available slot (5000) until that is "freed", and then I would get the same 5000 again?  any chance to actually make it random?

Lorenzo Miniero

unread,
Mar 23, 2020, 7:38:03 AM3/23/20
to meetecho-janus
Il giorno lunedì 23 marzo 2020 12:33:33 UTC+1, Kaplan ha scritto:
thanks for the info!. yes, I keep getting the same 10000 "random" port after I tear down the mount-point, and re-create it, but there is "something" sending data there (not something of mine) , so I get the new source over and over message, and audio is choppy..
so if I comfigure a range, say from 5000-65000, if I pass "0" as the port, will I always get the first available slot (5000) until that is "freed", and then I would get the same 5000 again?  any chance to actually make it random?



No, because this was an optimization. To make it random, we'd have to try a bind, close it if it succeeded on a port outside of the range, try again, etc., which can take forever if you have a small range and a limited set of free ports.

L.

Kaplan

unread,
Mar 23, 2020, 7:47:58 AM3/23/20
to meetecho-janus
OK, thanks. Long ago, when I coded in C, I thought that calling bind(0) or something like that, gave you a FREE randomly assigned port. the port ranges can be configured at the OS level, so you would never fail to bind. I guess since you want to specify a range in Janus vs the OS, you don't have that luxury.

The issue with reusing ports, at least for me, is that sometimes external RTP sources get stuck or missbehave, and I want to re-create a mount point in Janus, and use a random port to fix the issue with the external source.

Lorenzo Miniero

unread,
Mar 23, 2020, 7:52:19 AM3/23/20
to meetecho-janus
Yes, we cannot rely on that, because core and different plugins may have different ranges. You can try randomizing on your end and provide a port yourself, even though that might return an error if the port isn't actually free. We can try having the slider not start from the beginning but frm the last picked port, but we're swamped right now so no idea when I'd be able to work on that. As usual, pull requests are welcome.

L.

Kaplan

unread,
Mar 23, 2020, 8:22:54 AM3/23/20
to meetecho-janus
Thanks! yes, I ended up randomizing on my end :) 
Thanks for all you do! 
Reply all
Reply to author
Forward
0 new messages