Reputation: 33
I have two cordova ionic apps, which needs to communicate using sockets. is there any solution or plugin in cordova, in which i can create one server application and other as client application to start communicate. is there any solution or example that can resolve that issue. any help will be greatly appreciated thanks.
Upvotes: 1
Views: 1651
Reputation: 33
Thanx all for your response and help truly appreciated, i made it done with chrome tcp socket although i dont have info of peer devices i.e. IP of peer devices, for that i have to use three different cordova plugins to establish peer to peer communication.
Upvotes: 1
Reputation: 1742
The answer is Yes and No.
One mobile as socket server, the other as socket client(not in same LAN), without any other server. No! Because as you said in the comment, you don't know the ip address of the server mobile phone.(And in some countries, the ip address of 4G mobile phone is an internal LAN ip address)
Build your own socket.io server. All clients connect thru the socket.io server. But this is not what you want, so No, again!
Around 85% Yes. Use a Free STUN server for a peer to peer connection. In my previous Cordova App, I use 'easyrtc', which is a free audio/video chat api for peer to peer connection. Why 85%? Because a STUN server cannot guarantee a successful connection between 2 mobile phones, if, e.g. one of the mobile phone is behind a 'Super Firewall'! You'll need a TURN server, something like no. 2 to guarantee 100% successful connectiom. But I can't find any Free TURN server in the Internet. This kind of technology is called WebRTC. (Web Real Time Communication)
Upvotes: 1
Reputation: 2460
You don't necessarily have to use a Cordova-based one, but feel free to take a look at sockets-for-cordova. A popular one that isn't Cordova-based is but works with Cordova just fine is Sockets.io
Upvotes: 2