Whether STUN server is needed within LAN for WebRTC?
Asked Answered
A

2

18

I have developed a p2p video chat using Webrtc. I am aware that STUN or TURN server is required to identify the public IP behind NAT. Currently am using Google's STUN server.

I have the application installed in the server connected to the LAN which will not have internet access, do I need to install the STUN server in my server to make Webrtc video chat work within the LAN?

Accusative answered 30/10, 2013 at 6:18 Comment(1)
Were you able to configure candidates on the hosts in the LAN, as in your question to Sam?Sanctuary
P
12

Peers should be able to connect within a LAN (on the same side of a NAT) without STUN, i.e. using the host candidates. Try it out!

Pyromania answered 30/10, 2013 at 12:11 Comment(7)
Thanks for the post, can you please elaborate how to implement using the host candidates.Accusative
var peer = new PeerConnection(iceServers, optional); where iceServers = null this is working without internet.Accusative
Note that on the Android API iceServers can't be null or Collections.EMPTY_LIST. Must be a new ArrayList() or similar.Costate
Is unidirectional communication on the DataChannel from host1 to host2, with only host2 reachable in the WAN, theoretically possible without STUN/TURN? The use case is a client streaming unidirectionally to the server. Is this possible or this use case is not really covered by WebRTC?Sanctuary
I answer myself: WebRTC from host1 to host2 without STUN/TURN in the internet is theoretically possible assuming host2 has has open/reachable TCP/UDP ports for the data communication sockets. Also clients would still need to figure it out real public IP adresss of host2, since host2 can't reliably provide it, which is something that some browser clients can't do. Basically, this would require a custom WebRTC implementation which doesn't exist.Sanctuary
@Sanctuary can you elaborate on why host2 cannot reliably provide it's own IP? you mean from within the isolated native js window/browser environment with normal access and sandboxing? If I understand you correctly, this may be done, but perhaps would require low level access like through a browser extension, to be able to get the true public IP, correct? Ofc could also ping like whatismyip.com via ajax but then may as well do STUN/TURNKure
@Accusative if you are using the official WebRTC API without any library, it is called RTCPeerConnection and it can also be used without any parameter on a LAN.Croquette
A
2

In general, you won't need a STUN server. However, depending on the firewall configuration, you may actually need STUN (and even TURN). For example, at the SFHTML5 WebRTC Hackathon, we were on a corporate guest WiFi network that blocked local UDP and TCP traffic. Making successful calls required a TURN server in this case.

Abdu answered 30/10, 2013 at 14:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.