Question about Godot WebRTC signaling demo

Godot Version 4.2.2

Question

I’ve been trying for a while to set up a p2p connection using webRTC.

I finally manage to set up everything.
A STUN/TURN server (coturn)
and a signaling server (node)

All based on this demo godot-demo-projects/networking/webrtc_signaling at master · godotengine/godot-demo-projects · GitHub

Everything works fine but. The peer.initialize() (godot-demo-projects/networking/webrtc_signaling/client/multiplayer_client.gd at master · godotengine/godot-demo-projects · GitHub → line 35) function seem to make no difference if I add a turn server or not.

The project will work with or without it.

I vaguely remember that I’ve heard somewhere that Godot may use its own STUN/TURN server when one is not initialized. Tho I am not sure how to confirm that.

If Godot its not using its own server then is the TURN part necessary at all? When is it necessary?

A TURN server ensures 2 peers can connect to each other when other options (STUN) have failed. It does this by relaying the network traffic through a TURN server.

Note that at that point its not really “p2p” anymore, as connections are not directly between 2 peers, but routed through e.g. coturn.

Whether 2 peers can connect to each other depends on both their local network. For example, a router may not do NAT properly, which means external help (TURN) is needed to connect anyway.

Yes that is correct.

Here is what I tested so far:
If the connection is made only with the signaling server (node.js) everything works but the messages are being relayed by the signaling server (sealing the connection will NOT be possible if there is no STUN server in the peer.initialize)

It seems to me that the signaling server also acts as a TURN server.

I also configured a TURN server in coturn on a separate port, and added it in peer.initialize().

I do not know what difference does this make or even if this TURN server is used.

There are 3 elements:

  1. Coturn STUN
  2. Coturn TURN
  • When and how is this used?
  • How should I test this?
  1. Node Signaling Server/Godot Signaling Server
  • seem to act as a TURN server as well.

Note:
In the signaling demo they use only a STUN server in peer.initialize()

Can you not have anymore than 2 peers connect to each other?

You can, he mentioned 2 as an example.