1

I know this may sound a little silly (I'm new to native android and network stuff), but I want to build a peer 2 peer Android chat application (over the internet) where the chat payload shouldn't pass through a server. I've read numerous articles about the networking model and how it can be done.

I know that a Socket connection comes as a solution when you want to build this kind of application, but it will only work on the same network. And when you want it to work over the internet you need to add NAT traversal, hole punching, or port forwarding which from I've read, it seems impractical.

Then I saw how WebRTC can do the job by utilizing a signaling server, STUN server, and the last option, that is the TURN server (in the end, we pass the data through it) from here. I can use the DataChannel only for the chatting feature. I know that for signaling server, we can utilize something like Firestore (as what he did), and there are some STUN and TURN that we can access publicly.

enter image description here

My question is is it the right way to develop the chat application using WebRTC protocol? Since what I learn from the WebRTC video-audio stream it requires both of the peers to be online simultaneously. Am I on the right track? Or should I just go back to implement the original way with client-server model, then apply p2p encryption for the message. It would be great if you also mention where can I learn to implement those stuff e.g. tutorial, docs.

Any advice would be appreciated, thx in advance.

Naufal Rajabi
  • 334
  • 4
  • 13

1 Answers1

0

Short answer

client-server model is way more practical then WebRTC to develop a text messaging app. But if you want to include audio-video communication ,then use WebRTC. But don't use WebRTC for all three functions.

PS: You can develop a text messaging app with WebRTC but receiver might end up with corrupted data sometime.

aditya
  • 66
  • 4