meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.23k stars 2.48k forks source link

[1.x] Janus cannot handle more than 150 mids in a subscription #3276

Closed petarminchev closed 11 months ago

petarminchev commented 1 year ago

We did a load-test with 100 videos/audios (200 mids) on latest Janus 1.2.0 and noticed there is some arbitrary limit for the amount of mids. You can see how 151 mid is not properly printed and gets truncated which leads to browser throw an exception and whole subscription to fail. I think the limit is length 512 of some buffer somewhere, because I measured the length of string where it cuts and it cuts at exactly position 512 which suspiciously is a power of two.

a=group:BUNDLE 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 15a=ice-options:trickle

I think this limit should be lifted off with some much larger number - at least 1024 as a length - maybe even more.

Thanks in advance!

lminiero commented 1 year ago

Yeah it's probably buffer_part here, since it's used to chain the mids to build the group:BUNDLE line.

petarminchev commented 1 year ago

What do you recommend as a size? I can try to do a PR with the increased buffer_part size - e.g. 2048. That 2048 length should handle around 534 mids = 267 video + audio. Any drawbacks to just increasing the length? Is there something more to be checked?

Edit: Actually the issue may be in the following block, which prints the final value:

janus_sdp_attribute *janus_sdp_attribute_create(const char *name, const char *value, ...) {
    if(!name)
        return NULL;
    janus_sdp_attribute *a = g_malloc(sizeof(janus_sdp_attribute));
    g_atomic_int_set(&a->destroyed, 0);
    janus_refcount_init(&a->ref, janus_sdp_attribute_free);
    a->name = g_strdup(name);
    a->direction = JANUS_SDP_DEFAULT;
    a->value = NULL;
    if(value) {
        **char buffer[512];**
petarminchev commented 1 year ago

Opened a pull request - https://github.com/meetecho/janus-gateway/pull/3282. Did a load-test to confirm I can have my 100 video + audio.

lminiero commented 11 months ago

PR was merged.