Hi,
Is there is a way to make peer-to-peer connection with godot in all platforms?
I know there is UPNP but it doesnt works on mobile.
Is there is another way?
If ıpv4 cant, maybe ıpv6 do this?
Is there is a way to do it without server?
Thanks!
The problem with peer-to-peer is that all clients need to be directly reachable, and this can’t be done on mobile connections due to their use of CGNAT or similar features that make their IPv4 not directly routable. Also, IPv6 support on mobile connections isn’t that widespread yet in most countries – and when you do have IPv6, it’s often firewalled with no way for users to opt out of that firewall.
The only alternative you have is to rely on STUN and TURN servers (via WebRTC), but this isn’t supported by ENet.
Also, while some free STUN servers exist, you’ll have to pay to host a TURN server for the ~10% of clients who can’t rely on a STUN server alone. This is because TURN requires much more bandwidth as it relies all traffic through the server, as opposed to using the server only to perform the initial hole punching.
STUN only works in situations where the client has their own IPv4 or IPv6 behind a standard firewall. It won’t suffice for users behind a CGNAT, a mobile connection, or a corporate/university connection with aggressive firewall rules.
This is a very complicated topic. Browsers try this for WebRTC video-conferencing:
Maybe you can somewhere find a library that implements this procedure. You would still need TURN servers for some clients though AND you initially need a signalling connection that can relay information between the clients, so they can coordinate while searching for a path.
Thanks for you reply @Calinou
That means without server it cant be done in mobile?
And can I make my STUN/TURN server,
Or can I use a regular website server as STUN/TURN server?
And can you answer this question also: (if you know) Thanks!
Yes of course it can possible. But I dont have enough knowledge with making plugins for godot. If you can show me a tutorial for it, it will help so much
I don’t have a lot of experience with extensions either.
One of the available languages for this library is Rust. I have followed this tutorial the other day and the result was an extension that gave me a custom node in Godot: https://godot-rust.github.io/book/intro/setup.html
Getting your plan to work is probably possible, but very complicated.
thanks for your reply @joviansettler !
I found some tutorials about making plugins. I will check what it gives.
I dont know anything about rust but I can try to understand.
But anyway the libp2p looks very interest. Do you have more source about it?
Yes, it is possible to establish peer-to-peer connections across all platforms using Godot. While UPNP is not a reliable solution, especially on mobile devices, there are alternative approaches:
NAT Punching: This method involves using a third-party server to facilitate the connection between peers. The server helps the peers to discover each other’s IP addresses and port numbers, allowing them to establish a direct connection. Godot provides a built-in NAT Punching implementation.
Hole Punching: Similar to NAT Punching, hole punching is a technique that allows peers to establish a connection by sending simultaneous connection requests to each other. This method can be used when both peers are behind a NAT.
Relay Servers: Another approach is to use a relay server that acts as an intermediary between peers. The relay server forwards data between the peers, enabling communication. This method requires a dedicated server, but it can provide a reliable peer-to-peer connection.
Libraries and frameworks: There are libraries and frameworks available that provide peer-to-peer connectivity, such as:
libp2p: A decentralized network library that provides peer-to-peer connectivity.
Webrtc: A set of APIs for real-time communication over peer-to-peer connections.
Regarding IPv6, it does provide better support for peer-to-peer connections due to its built-in support for end-to-end connectivity. However, its adoption is still limited, and it may not be a viable solution for all platforms.
In summary, while there is no single, straightforward way to establish peer-to-peer connections across all platforms, Godot provides built-in support for NAT Punching, and other libraries and frameworks can be used to achieve peer-to-peer connectivity.