Need api for config different annoucedIp for H5 producer/consumer

Here is the code fragment i use for webrtc server:

const ip = require('ip');
const local_ip_address = ip.address() 
...
          webRtcTransport: {
            listenIps: [
              {
                ip: local_ip_address,
                announcedIp: configOptions.announcedIp || local_ip_address //process.env.ENV_HOST_IP
              }
            ],

However i find a problem:
I’m building a demo for streaming WebGL rendered web page content to WebRTC via Electron.

The electron instance(H5 producer) and webrtc server are running in a internal host behind gateway, (gateway opens port mapping)
The H5 page consumer is outside of gateway,
However, it seems outside H5 page consumer can connect to webrtc server, but The electron instance as H5 producer cannot.

I doubt if it’s due to the single annoucedIp config? The localhost electron H5 producer should directly use “127.0.0.1”, while outside H5 consumer uses mapped public ip?

From webrtcserver’s log, i can see locahost Electron as H5 producer can connect to webrtcserver via WebSocket, but no further SDP or RTP packet log.

I’m starting to think if it’s Electron’s bug(running on a server side centos machine with GPU)…

Previously i use a PlainTransport RTP producer(just a nodejs wrapper with ffmpeg/gstreamer) in the internal same host, there is no problem.

But PlainTransport has no full-functional WebRTC//RTCP feedback support…

You need to ignore loopback IP.

  const os = require('os')
  const ifaces = os.networkInterfaces()
  for (let dev in ifaces) {
    ifaces[dev].forEach((details, alias) => {
      if (details.family === 'IPv4' && details.address !== '127.0.0.1' && !details.internal) {
        console.error(details.address)
      }
    })
  }

What does this code mean? It doesn’t apply anything special to mediasoup settings.

I’m expecting mediasoup to support 2 anouncedIps per single instance:

One is for electron producer on the same node behind NAT gateway with mediasoup, “127.0.0.1” is OK;
The other is NAT gateway’s public ip for outside chrome browser page consumer to access.

Server behind NAT and the announcedIp - #9 by ibc is related.

Perhaps i need to tweak into mediasoup’s internal ICE-lite implementations to solve this, any suggestion would be appreciated!

Due to Cannot setup WebRTCTransport to mediasoup server inside of Docker instance, using ip 127.0.0.1(gstreamer pipeline cmd publisher in docker) - #19 by ibc

I mean, to let mediasoup to use node’s internal LAN ip(in fact it’s localhost) for the same-host electron producer.

Hi, i thought maybe i could create 2 routes: one is for the same-host electron producer instance, using local lan ip(not 127.0.0.1, since chrome doesn’t support it), the other for outside chrome page clients, using gateway’s public ip,

Then use pipeTransport to combine the 2 route…

Seems possible, and a little complex. I’ll try.

After re-looking at the API document, and the code which i modified from sample, I realize that, as to mediasoup, there is 3 hierarchies:

worker → router → transport

listenIp/anounceIp is transport-level config, so i can created 2 different WebRtcTransport using different listenIp/anounceIp config for internal electron producer and outside chrome consumers, they’re in the same router!

webRtcTransport: { //this is for outside chrome page consumer clients;
    listenIps: [
      {
        ip: local_ip_address,
        announcedIp: configOptions.announcedIp
      }
    ],
    maxIncomingBitrate: 15000000,
    initialAvailableOutgoingBitrate: 1000000,
  },
  webRtcTransportForSameHost: {//for electron producer instance on same node;
    listenIps: [
      {
        ip: local_ip_address,
        announcedIp: local_ip_address //<--  here;
      }
    ],
    maxIncomingBitrate: 15000000,
    initialAvailableOutgoingBitrate: 1000000,
  }

seems working