# Was producer map removed?

**URL:** <https://mediasoup.discourse.group/t/was-producer-map-removed/3604>\
**Category:** Off Topic\
**Created:** [November 19, 2021, 6:40pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604 "2021-11-19T18:40:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 19, 2021, 6:40pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/1 "2021-11-19T18:40:43Z")

</div>

I noticed WebRTCTransport does not contain producers map, is this intentional? I swear it was there before, I see:  
getProducerById  
getDataProducerById  
consumers  
dataProducers  
dataConsumers

No producers in this list. Thanks for understanding. I use latest 3.9.2 not sure when this got adjusted or if it was, hoping it’s not a me problem.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [November 19, 2021, 6:49pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/2 "2021-11-19T18:49:23Z")

</div>

That’s never been public api

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 19, 2021, 6:52pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/3 "2021-11-19T18:52:15Z")

</div>

Yeah not sure I had seen it listed, but was using it to retrieve producers from users transports. So was this removed then?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [November 19, 2021, 7:05pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/4 "2021-11-19T19:05:00Z")

</div>

Just public api is guaranteed to be kept. Other things are internal stuff and apps should not rely on them. There is a long discussion about this in a recently closed issue or PR in GitHub.

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 19, 2021, 7:14pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/5 "2021-11-19T19:14:57Z")

</div>

Appreciate the response, that makes sense. I can add the values to appdata no issues! 🙂

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [November 19, 2021, 8:08pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/6 "2021-11-19T20:08:34Z")

</div>

I’m surprised how many people used private undocumented API 😮

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 19, 2021, 8:17pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/7 "2021-11-19T20:17:44Z")

</div>

Haha were other people using this?

I was convinced it was just not written in documentation yet. Ooops

---

<div class="post-metadata">

**Author:** ![nazar-pc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/nazar-pc/32/369_2.png) [@nazar-pc](https://mediasoup.discourse.group/u/nazar-pc)\
**Post date:** [November 19, 2021, 8:23pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/8 "2021-11-19T20:23:03Z")

</div>

Yeah, some relied on `_*` properties in various places too

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 19, 2021, 8:32pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/9 "2021-11-19T20:32:06Z")

</div>

I know I “did”; no foul though appData works fine. Good to know to not do that, think it was an early mistake or with how I was signaling I required it but no foul.

Appreciate the fast response, I was reinstalling media-soup a few times like, huh.

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 20, 2021, 12:46am UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/10 "2021-11-20T00:46:45Z")

</div>

Curious, why was this removed? Was it due to efficiency or problems internally? Being private no documentation I wonder, but perhaps it’s a mistake to?

Appreciate you guys!

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [November 20, 2021, 4:20am UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/11 "2021-11-20T04:20:59Z")

</div>

It’s there but now it’s `#producers` instead of `_producers`, so now it’s real JS private field.

---

<div class="post-metadata">

**Author:** ![snnz](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/snnz/32/693_2.png) [@snnz](https://mediasoup.discourse.group/u/snnz)\
**Post date:** [November 20, 2021, 11:55am UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/12 "2021-11-20T11:55:33Z")

</div>

Similar questions seems to be repeated on and on. May I ask what’s the rationale for keeping those collections completely private? Why not make public read-only iterators for enumerating producers and consumers in the transports and routers in the workers, as well as indexers for getting these items by ids?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [November 20, 2021, 12:40pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/13 "2021-11-20T12:40:52Z")

</div>

> <https://github.com/versatica/mediasoup/issues/700>
>
> \## Feature Request
> 
> Given that the Consumer's \`transportId\` is already \[right …there\](https://github.com/versatica/mediasoup/blob/053c2e08c6b7cb1880ce390ad58308d9fdcbf6dc/node/src/Consumer.ts#L165), I'd like to propose that applications can save having to keep an extra dictionary of \<Consumer, Transport\>, and instead be able to simply read the Transport ID from the Consumer itself. This is also safer and less error prone, having a single "source of truth".
> 
> My request is for Consumers, but I guess the same could be said about Producers.
> 
> The getter code seems that would be trivial to add, just like there already is a \`Consumer.producerId()\` getter, it would be a \`Consumer.transportId()\` getter.
> 
> If this idea seems reasonable and gets an OK, I can file a PR with the change.

Rationale there. I’m afraid that many people have been accessing and relying on private API but definitely not my problem. The public API is clearly documented.

---

<div class="post-metadata">

**Author:** ![snnz](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/snnz/32/693_2.png) [@snnz](https://mediasoup.discourse.group/u/snnz)\
**Post date:** [November 20, 2021, 1:12pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/14 "2021-11-20T13:12:38Z")

</div>

> [@ibc](#):
>
> Rationale there.

Sorry, but I do not understand.

> “I have called `consumer = transport.consume()` but later I don’t know in which transport I created that consumer”

Suppose I _know_ exactly in which transport I created the consumer with the given id. I believe it is a common practice that transports are associated with peers, and mapping the peers to the transports is a task for the user app. But then, knowing that the consumer is there, I just want to get a reference to it. What wrong with that? Why do I need to hold a duplicate external collection of consumers that belong to the particular transport? What “doors” will open the public indexer and the iterator? Will consumers be shifted from one transport to another without my knowledge or what?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [November 20, 2021, 1:25pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/15 "2021-11-20T13:25:30Z")

</div>

Whatever task that can be easily done by the user app won’t be provided by mediasoup. That’s the philosophy. I’ve built tons of apps on top of mediasoup and have never needed to get a list of Consumers per Transport. And if I needed it, I could make a simple logic to hold them within my app. mediasoup is never gonna provide the user app with sugar api or opinionated api.

---

<div class="post-metadata">

**Author:** ![snnz](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/snnz/32/693_2.png) [@snnz](https://mediasoup.discourse.group/u/snnz)\
**Post date:** [November 20, 2021, 1:39pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/16 "2021-11-20T13:39:05Z")

</div>

Well, for once I cannot agree with that. The api that brings optimization (makes a duplicate map unnecessary) at no cost is not a sugar api.

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 20, 2021, 2:55pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/17 "2021-11-20T14:55:26Z")

</div>

Duplicated maps cost nothing unless we’re dealing with millions but a 1core-\>64core instance would never have such use case so it’s no inefficiency there. Simply an inconvenience for those that spent long hours coding with these private apis.

Fortunately for me it was a matter of adding producers to appData and keeping track that way, but for global search I had mapped the room and user handle. Ex.  
Transport.get(roomname).get(userhandle)

So if I loop through a room or its users I can still through appData get their producers, if there’s active consumers which pipes/networks they belong to, how much they’ve been consumed.

I’ll admit, using the private API I didn’t think was a risk but I get it fully, there’s better ways to setup and IBC just trying to apply the dankest standards. No foul here and hope others can adjust. IBC you do amazing work, this is one slip up for me but answered quickly and is no problem.

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 20, 2021, 3:03pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/18 "2021-11-20T15:03:42Z")

</div>

I would ask @ibc if you could maybe reconsider; this is useful stuff for public API. However if this slows the soup process down or hinders it any, I’m in all favor. Stay lit.

---

<div class="post-metadata">

**Author:** ![snnz](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/snnz/32/693_2.png) [@snnz](https://mediasoup.discourse.group/u/snnz)\
**Post date:** [November 20, 2021, 3:05pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/19 "2021-11-20T15:05:51Z")

</div>

> [@BronzedBroth](#):
>
> Duplicated maps cost nothing

Then the primary maps with read-only public access cost less than nothing. 🙂

---

<div class="post-metadata">

**Author:** ![BronzedBroth](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@BronzedBroth](https://mediasoup.discourse.group/u/BronzedBroth)\
**Post date:** [November 20, 2021, 3:09pm UTC](https://mediasoup.discourse.group/t/was-producer-map-removed/3604/20 "2021-11-20T15:09:54Z")

</div>

In theory yes, unless there is a loop that repeatedly had to check these maps then there’s added delay in processing. Containing large maps no concern till then!
