P2P connection problems on Mobile (Cellular) Data

Hello. I’ve been testing with multiplayer P2P games powered by THNK and have noticed that whenever I tried to join a lobby while connected on mobile (cellular) data, it does not work, but when connecting over wi-fi or ethernet there are no issues.

This is one of the game examples where you can try it out:

Does anyone know what can be done about this?

I checked the connection with the broker server and even when on mobile data it is successful and it shows the connection code. However, when trying to join that lobby from another device on another network (regardless of it being on wifi or cellular), it does not work.

After more testing, other games from gd.games that are made with the built in multiplayer work with mobile data, but those made with P2P THNK don’t connect over mobile data.

My own game has this issue too and I don’t want to switch to the built in GDevelop multiplayer because the lobby system has no way to hide the lobbies or make them with passwords and it allows anyone on the planet to join, which is not a good thing for a game made for children. It’s why I went with THNK, because only people who you give the code can join.

What I find weird is that it did work over mobile data months ago, and now it does not work for any of the THNK GDevelop games, not mine nor anyone else’s, from what I tested.

Right now I’m at a dead end with searching for what could be causing this.

@arthuro555 if it’s possible, can you offer me some insight on this?

Thank you very much.

it’s working for me cool
how did you make the id smaller

Is it working for you playing multiplayer on mobile data, and on two different devices not on the same network? For me it works on single player, but that can work completely offline as well. The issue on mobile data is trying to connect to a different device.

As for the smaller id, you need to make your own broker server, which means you need to host that server (ideally on a paid hosting service so it is available at all times). For more instructions you can check this out:
https://wiki.gdevelop.io/gdevelop5/all-features/p2p/#selecting-a-broker-server
The “Set up a custom (local) server” section

it works for me with two different devices
thanks for the info

The GDevelop company provides TURN servers, but only when using GDevelop lobbies.
With normal P2P, you need to set TURN servers up and register them before connecting to the broker using the “Register ICE candidate” action.

TURN servers are required to establish connections on restricted networks that block P2P connections, by allowing both devices to connect to it with a client-server connection and relay messages from one to the other.
You can find some companies that provide TURN server hosting for you:

Thank you for the tip. I will consider making dedicated servers for my own game in the future.

I have tested the game since the time I’ve made the post and my results have been inconsistent. On the day of the post I have tried P2P connections over mobile data, and it never connected. However, on the day after, and today, I’ve made some more tests and it has connected some of the times, and here are the observations:

  • If I connect over WiFi/Ethernet, connection is flawless every time
  • If one of the devices is on a Mobile Data network, then it depends on the service provider, but the connection is not as instant as with more reliable WiFi, and it takes a while to actually switch the scene to the one initialised with THNK, sometimes having to spam click the join button, which most of the time ends up in a situation where the client is de-synced and unable to see things moving on their screen
  • A device that is on Mobile Data can both host and join a P2P game, so it doesn’t seem to matter if it behaves as client or server
  • If both of the devices trying to connect are on Mobile Data, it hasn’t allowed me to make a connection at all
  • Another interesting thing to point out is that if I press the join button on a device that’s on Mobile Data and quickly switch to WiFi fast enough to not disconnect, it will actually connect to the server despite having changed the network it was connected to

This leads me to believe that there is some sort of problem with the way or amount of data transferred between the server and client during the connection process, which may result into the attempt at connection timing out or overloading, but I’m not sure how to test that theory, and where exactly it should be changed, in THNK or vanilla P2P in GDevelop.

So, since you know about this kind of stuff more than me, is there a way to see or change something in the P2P connection initialisation?

Ah, THNK does not switch scenes until an initial remote scene description has been sent over by the server. It could be that in some scenarios, even if the connection is established correctly, that this payload is somehow lost or corrupted, and thus THNK would seem to have not connected, as it would not proceed or retry the connection, whereas the built-in multiplayer does not wait for such a thing as far as I can remember. I’d need to look into it…

Thank you for your interest in helping me solve the problem. I’ll keep you updated if I have any news regarding the issue, and if you have any I’ll really appreciate if you’d let me know.

Also, I wanted to thank you for the amazing work you’ve done with the extension, and I’ve also credited you in my game here: