Is XMPP peer to peer connection without server possible? - xmpp

I am using libjingle for my XMPP connection. Can I connect two XMPP clients without having server in between. If yes how can I do that if no then why it is not possible?
XMPP client1 <---------Direct Audio/Video/IM----------> XMPP client2

You may not be able to do this directly with libjingle, but a protocol specification exists in the form of XEP-0174. The gist is that you publish your presence and connection information over Multicast DNS (e.g. Bonjour), then connect directly when you want to chat. Apple's iChat
implements essentially this approach for its peer-to-peer mode.

WebRTC is perfect example for having peer to peer connection. The answer I was looking for two years ago.

Related

Is there a way to use XMPP protocol to make P2P instant messaging using Pidgin client?

I want to to use Pidgin as a instant messaging client. Then I want to make peer-to-peer connection using XMPP protocol. I do not want to use a solution including a server.
I have try and inspect those things below:
XMPP protocol says it is a decentralized solution for im and it needs 'servers',
Official XMPP web site also states that there is an extention for serverless messaging, but i do not get it and how to implement it in pidgin?
The official XMPP states there is something called Jingle, and through jingle anyone can send media/files peer-to-peer. But if I didn't understand wrong as a client I still connected to a server?,
11 years ago this question had been asked:Is XMPP peer to peer connection without server possible? Unfortunately who asked the question was looking for something like WebRTC. Check the answers. This is not what i am looking for.
Also there's 'ejabberd'. If you use ejabberd you still make connection to ejabberd daemon and you are not instant messaging peer-to-peer. Host Unknown - XMPP Pidgin
So my question is simple: By using "pidgin" as a client and "xmpp" as protocol; is it possible to make peer-to-peer instant messaging? And if it is possible, how can I make it?
Thank you.

Reconnection issues with openfire

i am using openfire xmpp server and asmack library to implement chat service , the biggest issue that i face is the reconnection problem to the xmpp server.
whenever a connection is made to the xmpp server there are lots of stanza is being exchanged possibly around 5 to 7 stanza in a desktop applicaiton or web application it seems ok , but for mobile application where 3G link is pretty weak , in that case it too good to exchange so much of stanza.
i have tested that when the wifi has a weak signal or 3g link is down , i am making a reconnecting to the server (in background process) but i mostly get a response time out error and taking too much time if the connection gets successful.
i have seen messenger like whatsapp in which they are making a reconnection pretty fast. i want to do something like that only.
i have read about the pre-http binding but its exist in ejabber but didnt find anything in openfire moreover htt-prebinding is for anonymous users and i am using registered users only.
so can anyone tell me how can i reconnect fast to the xmpp server.
while exploring i saw xmpp protocol XEP 0198 to resume the streaming session but it seems openfire doesnt support this so can anyone tell me what is the better and faster way to reconnect to the openfire server when network link goes down.Please help me.
Your openfire version is too old,the newer is supported for session resume,by the way asmack is deprecated you can switch it to smack.here is github address:
https://github.com/igniterealtime/Smack.git

Simple chat app (Should I use sockets? And would Apple app store approve that?)

I have an idea of an application that involves a "chat feature", basically an ability for people to chat with each other. Since sending messages through a server would be slow (plus it would be pretty bad having to check the server every second if you have new messages) I want to use sockets to have peer to peer chat ability instead of going through a server.
My 2 questions:
1) Is socket programming the most optimal way to develop a chat program? I know there is push notification service, but I don't think it can be used for a chat program too well. Going through a server seems kind of bad if you imagine 5,000 people chatting and having to poll the server every second.
2) Will Apple have issues approving an app that has peer to peer chat program that uses sockets?
Thank you.
Sockets are indeed appropriate. But you are better off with a client/server approach rather than a P2P approach.
Having worked on a very well known instant messaging service for many years, I can tell you absolutely that going through a server is not slow - as long as your server is not slow.
Client/server has lots of advantages. Namely, it's not as difficult as any sort of P2P connectivity where such issues as NATs and Firewalls make direct socket connections difficult and unreliable. Besides, you would need a messaging service anyway for clients to exchange IP addresses.
Your stated assumption that a client or server would have to "poll" is not how scalable systems work. You should use a persistent TCP socket and look at scaling a socket service up though any of the available async methods that exist today. select(), poll(), epoll on Linux, and IO Completion Ports on Windows are all techniques for having thousands of sockets simultaneously connected without periodic polling.
My suggestion - just deploy an XMPP/Jabber server. Most implementations scale up nicely to the thousands of clients. Then your chat program is just an XMPP client socket. Some of the Jabber servers even support HTTP connectivity for situations where a user's only access is via an http or http proxy server. I played around with Openfire a while back and was reasonably impresseed.
I'm fairly certain that iOS has sockets, and that it's allowed by Apple. I only know via second hand from folks that have worked on iOS products. You probably shouldn't use the push notification service for anything more than notifications to wake up your app that there is something it needs to do.
Hope this helps.

How does iChat start a conversation?

I want to know which protocol does iChat use to start a conversation with other client in LAN ?
is it SIP? or SIP + XMPP?
start a session with SIP and exchange message with XMPP?
thanks a lot!
It uses Bonjour, XMPP but using multicast DNS for presence, and peer-to-peer connections instead of a server. The protocol was designed by Apple and then openly documented by the XMPP Standards Foundation as XEP-0174: Serverless Messaging.
So, I understand how does ichat work now. DSN-SD + XEP-0174.
unfortunately there isn't any java library for XEP-0174, but the connection is based on socket.
thanks for everyone's attention.

iPhone (behind cellular NAT) peer-to-peer internet connection with a server

I have an iPhone on a 3G cellular network and a server on the internet and I want them to be able to exchange messages bidirectionally. Sometimes the iPhone makes a request to the Server some other times the Server makes a request to the iPhone. Problem is that the iPhone is behind the NAT of the cellular network and it doesn't have a fixed ip:port , on every new connection the port changes.
I think I have to make a bidirectional socket SO_REUSEADDR/SO_REUSEPORT and make the connection persistent.
The other two solutions are Apple's Push notification and long polling, for now I need an answer for the P2P solution between the iPhone and the Server.
Can you advise me on what I have to do or provide me a working example code where an iPhone can receive messages from a host that is on the internet?
It is a pity that Java is not supported on the iPhone, because the JXTA framework would have solved your issue easily.
What you are looking for is a TURN like implementation of P2P. The Iphone has to initiate the connection to the server to punch the hole in the NAT and yes, it has to be kept alive (even if you investigate more sophisticated implementations like STUNT for NAT traversal).
With TURN, the server has to transmit messages between IPhones, with STUNT, messages are transferred directly between devices, but it is quite complicated to implement properly.
i've been doing a lot of reading up on these things and my understanding is that XMPP is the solution for you. use an open source XMPP server (like openfire) and XMPPframework (an ios module).