Using XMPP to Build a Cutting-edge Chat Module

Mobile apps have truly revolutionized the way people interact with each other, with any network or different businesses. A little investment in a smartphone, opens up the gateway to the world of mobile apps. Likewise, now there are many mobile apps for Real Estate brokers and BroEx is leading the pack.

Our product BroEx is being used by 100,000+ brokers across the country. It helps them find relevant brokers on our platform, get connected, share inventories & requirements, and close deals successfully. However, after a deep dive into the user habits on our app, we analyzed that brokers are using the app to find other brokers but were communicating with them on WhatsApp. We wanted to extend the platform such that we can reliably handle the communication within the application itself. A good chat module is one of the most important feature in any social or professional network app and we needed the same for BroEx to have. As we looked around, we realized that while most of the popular apps have a chat feature, but they struggle to make it stable and reliable.

While the chat feature seems trivial from users’ perspective, it came with several daunting challenges and use cases when we set on route for implementing the same. Read more on a special use case below but first, let’s get started with the keywords and technology at core.

XMPP and Erlang powered Ejabberd

Extensible Messaging and Presence Protocol (XMPP) is a communications protocol for message-oriented middleware based on XML (Extensible Markup Language). It enables the near-real-time exchange of structured yet extensible data between any two or more network entities.

Erlang is a programming language used to build massively scalable soft real-time systems with requirements on high availability. Some of its uses are in telecoms, banking, e-commerce, computer telephony and instant messaging. Erlang’s runtime system has built-in support for concurrency, distribution and fault tolerance.

Ejabberd is an XMPP application server, written mainly in the Erlang programming language. It can run under several Unix-like operating systems such as Mac OS X, GNU/Linux, FreeBSD, NetBSD, OpenBSD and OpenSolaris.

There are several options available with respect to XMPP server software but Ejabberd clearly stood out above the rest for our use cases. You can find a detailed comparison on the XMPP server software available by clicking here.

Let’s trace a series of messages flowing back and forth. In the diagram below you can see what happens in the background when Alice sends a message to Bob.

edge_01

Looks pretty simple eh? Well, isn’t everything that is designed simple just awesome? Everything should be made as simple as possible, but no simpler ~ Albert Einstein

This looks easy and seamless but it happens only when the users are online. Twist and complete reliance on technology comes in when the receiver of the message is offline, and the message had to be delivered as soon as they came online.

Let’s talk about a major challenge that we faced with handling offline messages’ delivery

Have you ever used Tinder? When you tap on a notification for a message from your match, there are good chances that the message would not appear in the chat thread for at least a few seconds (this bug is present as of today. Isn’t that heart breaking?). This is a typical problem with many other popular chat applications as well, where the client app receives the notification from GCM/APN before a connection was established with the chat server and offline messages were retrieved. Well, here is how we have solved it. In the below diagram Alice has sent a message to Bob, but he is offline.

edge_02

The magic happens when BroEx app at Bob’s phone makes a stealth mode (Bob is not treated to be online) connection with XMPP and requests for all of their offline messages. XMPP server calculates and sends all the pending offline messages to Bob. The BroEx app at Bob’s phone then sends “received” acknowledgements to the server, which is then sent to Alice.

Now, when Bob would tap on the push notification he received from APN/GCM, he would see all the offline messages already present waiting to be read.

We are not alone in doing this! Check how WhatsApp used Erlang and XMPP to reach a multi-billion-dollar valuation. XMPP for the Win!

Team BroEx

BroEx is the largest go-to application platform for Real Estate Brokers to connect with each other to network and collaborate with each other to fulfill their business requirements reliably and quickly.

9 Comments

  1. It’s really a nice and useful piece of information. I’m satisfied that you shared this useful info with us. Please keep us up to date like this. Thank you for sharing.

    Here is my web-site: http://www.ukclassads.com

  2. I’m gone to convey my little brother, that he should also go to see this blog on regular basis to obtain updated from newest news update.|

  3. “I love the efforts you have put in this, thanks for all the great blog posts.”

  4. Saved as being a favorite, I really like your web
    site!

  5. Excellent, what a website it is! This website presents valuable data to us,
    keep it up.

  6. This post will assist the web users for creating new
    website or possibly a weblog from commence to end.

  7. Oh my goodness! Amazing article dude! Thanks, However
    I am just experiencing troubles with your RSS. I don’t understand exactly why
    I cannot join it. Is there anybody else getting the same RSS issues?
    Anyone who knows the perfect solution will you kindly respond?
    Thanx!!

  8. Right here is the perfect web site for everyone who would like to understand
    this topic. You realize so much its almost tough
    to argue with you (not that I really would want toHaHa).
    You certainly put a new spin on a topic that’s
    been written about for decades. Wonderful
    stuff, just wonderful!

  9. If you desire to grow your knowledge just keep visiting this site and also be
    updated with the most up-to-date news posted here.

Leave a Reply

Your email address will not be published. Required fields are marked *

We know you're human, still this is for your security. *