# Piping producers to other router with the same producer ID

**URL:** <https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614>\
**Category:** mediasoup libraries\
**Created:** [August 20, 2020, 11:07pm UTC](https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614 "2020-08-20T23:07:41Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [August 20, 2020, 11:07pm UTC](https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614/1 "2020-08-20T23:07:41Z")

</div>

I understand that producer ID must be unique, this is why it is generated automatically.

However when piping producers to other routers, it would have been extremely convenient to hide the implementation details and have the piped producer with the same exact producer ID as original.

We use this to map the same original source in multiple places, so this is out anchor across clients both server-side and client-side.  
With producerId being different on piped producer this unfortunately causes a bunch of inconveniences and requires a log of mappings back and forth (and yes, appData helps here, but only so far).

Thoughts on having such an option available to the developer?

---

<div class="post-metadata">

**Author:** ![ea167](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ea167/32/404_2.png) [@ea167](https://mediasoup.discourse.group/u/ea167)\
**Post date:** [August 21, 2020, 1:20am UTC](https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614/2 "2020-08-21T01:20:10Z")

</div>

@nazar-pc could you have as a workaround a producerId of the form {id}\_{sufx} with {sufx} related to the Router.id (or any other form of suffix)?  
When you need the “global” producerId, you strip the suffix, and conversely when you are in a given Router, you build the {id}\_{sufx} from the Router.id

---

<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:** [August 21, 2020, 1:28am UTC](https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614/3 "2020-08-21T01:28:20Z")

</div>

I’m afraid we’re talking about different things.  
My request is about `Producer.id`, which is auto-generated UUID inside of mediasoup internals. You can’t specify it externally at the moment.

I have already implemented everything necessary to map producers back and forth between routers, but with this feature (which should not be hard to implement technically) a lot of code and non-trivial logic would be gone.

---

<div class="post-metadata">

**Author:** ![ea167](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ea167/32/404_2.png) [@ea167](https://mediasoup.discourse.group/u/ea167)\
**Post date:** [August 21, 2020, 1:35am UTC](https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614/4 "2020-08-21T01:35:32Z")

</div>

Indeed! Good point, would definitely simplify that case.

---

<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:** [August 21, 2020, 9:31am UTC](https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614/5 "2020-08-21T09:31:06Z")

</div>

When using `pipeToRouter()` the generated pipe `Producer` in target router has the same `id` as the original `Producer`:

```auto
pipeProducer = await remotePipeTransport!.produce(
	{
		id : producer.id,
		kind : pipeConsumer!.kind,
		rtpParameters : pipeConsumer!.rtpParameters,
		paused : pipeConsumer!.producerPaused,
		appData : producer.appData
	});

```

---

<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:** [August 21, 2020, 9:47am UTC](https://mediasoup.discourse.group/t/piping-producers-to-other-router-with-the-same-producer-id/1614/6 "2020-08-21T09:47:14Z")

</div>

Oh, it does indeed. I was a bit overengineering things at 2AM 🙂
