pipeToRouter needs router from another host. How to get that?

Since pipeToRouter needs router not router id so I need to have a router object but router object is in different worker in different host so How do I get that router and pass to it?
Isn’t it would be better to just pass router id along with remote host ip so that mediasoup can lookup on that host for that router id and gets a connection?

This is a method purpose-built to work with multiple workers on the same host, see docs: mediasoup :: API


Pipes the given media or data producer into another router in the same host. It creates an underlying PipeTransport (if not previously created) that interconnects both routers.

It says it connects two routers. Now I have a worker running on different host with a router. Then how do I pipe producer stream to that router?

Follow the link in the text you quoted :wink:

As the docs say, that’s not a built in feature but you can develope it for your needs.

pipeTransport.connect() ?

Yes. I think I first have to create localPipeTransport on both server with each others ip then I call localPipeTransport.connect() on both server. Right?
and then save localpipetransport to peer.

In consumer part I also check if peer has pipetransport, if yes then I will also consume from that. I hope I am right.

For Remote (summed up I hope):

  1. Your signal server tells media-server-1 to
    let MyPipe = await Router.createPipeTransport({ “listenIp”: “”, “enableRtx”: true});
  2. You reference this transport to a server ID to clear out later but as well connect.
  3. Send signal server back the IP/Port with Server ID for reference.
  4. Signal server sends this information over to media-server-2 to then check if it had already been created the transport, and if not do so now (repeating step 1).
  5. Finish the connection with
    MyPipe.connect({ “ip”: Received.ip, “port”: Received.port });

Once their connected, it’s really about re-producing the broadcast on media-server-2 and allowing consumers to view the producer. :slight_smile: