Allow UPnP to open UDP ports automatically.
Libnice allows for one to enable UPnP port opening. I have used this feature in a modified Janus Server to allow for remote viewing without a STUN/TURN server acting as a broker. Worked great for that particular service, and I think it would also work very nicely for this application as well.
Seconded. My router does not allow me to specify a range of ports (a Huawei AX3 Pro), so this feature would come a lot in handy.
What I'm doing currently to circumvent this issue is to have https://github.com/snowzach/rts2p to route my camera's stream to my HA host and then I forward the 5554 port of my host to the external. Then, I set WebRTC to connect to the camera using:
rtsp://admin:[email protected]:5554/my_stream
But I think this is not optimized when accessing it internally, as the traffic would likely be routed outside in all cases.
@felipecrs I don't think your setup is doing what you hope. It is probably falling back to MSE. The webRTC component accesses the streams and pipes it out, the client (web browser and app) don't have any knowledge about the underlying RTSP stream.
@rbray89 I disabled MSE with:
webrtc: true
mse: false
Because it seems to be causing more issues than helping, especially when inside of the internal network.
So no, I'm not using it.
@felipecrs interesting, then I have no idea how your setup works for external viewing? Internal should be fine as long as your internal DNS redirects your hostname.
Hm... you may be right. Perhaps it is not doing what I expect it to do. I will perform some more tests...
Regardless, I think UPNP would be awesome.
It's indeed working:

@felipecrs I wonder if your carrier doesn't do NAT and exposes all ports? That's the only way I can think of that'd make sense, unless WebRTC is setup to use a STUN/TURN server (but I doubt that's the case).
IPV6 is also a possibility, as it is rarely NAT'd.
I don't think that's the case, as I have to setup port forwards for everything here, otherwise I can't access anything (like HA http port).
Also, I disabled any kind of IPV6 in my router, so I doubt that's the case as well.
@felipecrs is your mobile IP global or NAT'd? (Does your device have the same IP that Google says you have?) Cause the communications negotiation will go both ways to have either device open up a socket for connections from what I'm aware.
The WebRTC can make the tunnel through some NATs automatically. Without any port forwarding.
I guess that explains it then.
Check my new project. You don't need to forward UDP anymore https://github.com/AlexxIT/go2rtc