WebRTC icon indicating copy to clipboard operation
WebRTC copied to clipboard

Allow UPnP to open UDP ports automatically.

Open rbray89 opened this issue 4 years ago • 11 comments

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.

rbray89 avatar Oct 26 '21 06:10 rbray89

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 avatar Dec 19 '21 14:12 felipecrs

@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 avatar Dec 19 '21 16:12 rbray89

@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 avatar Dec 19 '21 16:12 felipecrs

@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.

rbray89 avatar Dec 19 '21 16:12 rbray89

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.

felipecrs avatar Dec 19 '21 16:12 felipecrs

It's indeed working:

image

felipecrs avatar Dec 19 '21 18:12 felipecrs

@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.

rbray89 avatar Dec 19 '21 20:12 rbray89

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 avatar Dec 19 '21 20:12 felipecrs

@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.

rbray89 avatar Dec 20 '21 00:12 rbray89

The WebRTC can make the tunnel through some NATs automatically. Without any port forwarding.

AlexxIT avatar Dec 20 '21 03:12 AlexxIT

I guess that explains it then.

felipecrs avatar Dec 20 '21 13:12 felipecrs

Check my new project. You don't need to forward UDP anymore https://github.com/AlexxIT/go2rtc

AlexxIT avatar Aug 21 '22 11:08 AlexxIT