How to create peer to peer chat system without a server?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pritish

Hello I am a mobile app developer. We had a requirement of sending data from one device to other via bluetooth or wifi without a server. I was able to send data from iOS to iOS. Android to android has been a little tough for me via Bluetooth and tried following code samples from google as well but they restrict the amount of data that I can pass as a string. I think it only passes 24 characters via chat in bluetooth. Transferring from android to iOS and vice versa is an absolute pain. I am not qualified enough to write a C++ implementation for this. Neither I know the internals of Bluetooth or wifi good enough to do this.

I have also used Near by messages api from Google and it is a nightmare to work with as it does not work as expected.

One of my friend suggested to look into how game engines does this. I came across Godot which is open source and extremely lightweight. I am planning to embed Godot Engine in my app just for one or two screens to achieve chat functionality without a server.

I was following this tutorial and had few questions on this

  1. Is this the right way of achieving peer to peer communication in my app without a server if I suck at integrating bluetooth or wifi.
  2. Is it possible to embed Godot in android or iOS app. If anyone has docs link for it it would be greatly appreciated. Specifically I am using React native so it will definitely complicate our project but I am happy to give it a try as I do have some knowledge of native mobile app development with kotlin and swift
  3. In the above YouTube video what is ‘’ which the YouTuber enters in the app. Is it public ip address. Is it possible to get public ip of my android and iOS device and will they be able to communicate with each other if they are on different ips with the above tutorial?
    Sorry I am pretty new to this stuff so some of my questions may sound little dumb.

Any peer to peer app requires a server. Most kind use a TCP server, others can use FTP or web servers. You can use the python addon for godot and make a python server on replit then use the hacker plan, or uptimerobot, to keep the server running. Or you can create a dedicated server and use only GDScript.

toivocat | 2022-05-13 17:11

:bust_in_silhouette: Reply From: cm
  1. Any game engine might be overkill for an embedded chat app. I suggest looking up TCP socket communication. However, if you’re set on using Godot for this then RPC based communication (which uses TCP/UDP under the hood) would be a viable choice.

  2. It looks like you might be able to embed/bundle a web export. See react-godot on github.

  3. is known as a loopback address. In this case it’s used as an easy way for the computer to refer to itself. For getting the external ip address in Godot see UPNP’s query_external_address method.

I just noticed that there is an open issue in react-godot about missing 3.3.2 support, so getting this project to function with 3.4.x might require some work.

cm | 2022-05-13 13:05