TwistingTwists

TwistingTwists

I know that Whatsapp uses some custom implementation of ejabberd. - which is used for messaging between two clients.

Since Phoenix PubSub also has that bi-directional communication over websockets,it CAN work be used in realtime (soft realtime, not accurate to the 1/100 of a second) .

I am confused between XMPP vs Phoenix PubSub. My questions are :sweat_smile:

  1. For what use cases XMPP is strictly better than Phoenix PubSub?
  2. What are the differences between ejabberd vs Phoenix PubSub ?

Showing Posts 1 to 10

hauleth

hauleth

These are completely orthogonal things.

  • XMPP is a protocol, just like HTTP or WebSocket
  • ejabberd is an implementation of server for such protocol in Erlang. Just like Cowboy is an implementation of server for HTTP/WebSockets.
  • Phoenix.PubSub is an helper library for exchanging messages between Erlang nodes.

It is not comparable at all.

TwistingTwists

TwistingTwists OP

Thanks for clarification.

I guess my question is :

  1. Phoenix.PubSub uses websockets, right?
  2. What advantages one gets via xmpp protocol over websockets?
  3. Can Phoenix.PubSub be extended to use xmpp ? If yes, one has to spin xmpp server (not default cowboy that Phoenix ships with), right?
cmo

cmo

Check out the docs for PubSub and Channels. I think you may be conflating the two.

Adapters
Phoenix PubSub was designed to be flexible and support multiple backends. There are two officially supported backends:

  • Phoenix.PubSub.PG2 - the default adapter that ships as part of Phoenix.PubSub. It uses Distributed Elixir, directly exchanging notifications between servers
  • Phoenix.PubSub.Redis - uses Redis to exchange data between servers. It requires the :phoenix_pubsub_redis dependency
  • See Phoenix.PubSub.Adapter to implement a custom adapter.
hauleth

hauleth

No, Phoenix.PubSub do not use WS, it do not use Phoenix at all. It is my biggest gripe with that library, that there is phoenix in its name. It is completely independent from any web or Phoenix technology. It uses defined transport (by default pg which uses Distributed Erlang), but it can use any other messaging technology out there.

These also are orthogonal. WebSocket is more like transport protocol (like TCP, but a little bit higher level as it utilises TCP underneath) and XMPP is data protocol (more like HTTP).

Technically - yes, but it would be IMHO a little bit pointless, as it would introduce a lot of overhead with encoding and decoding all that XMLs. So instead it would be better to use for example Kafka or PostgreSQL LISTEN/NOTIFY.

TwistingTwists

TwistingTwists OP

I will read more about protocols.

Thank you so much for clarifications.

derek-zhou

derek-zhou

I sense some X/Y problem here. It would probably be better if you state what objective you want to achieve first, so other people can make recommendations for you to choose from.

TwistingTwists

TwistingTwists OP

Thanks @derek-zhou
Indeed an X/Y problem. (thanks for naming it for me)

What I wanted - to make a simple chat application. with tracking.

I already achieved chat and tracking using Phoenix.Presence .

Then I came across ejabberd. And was confused as it also enables chatting and messaging. I did the same thing without it.

Why would I need to use ejabberd at all ?
Why bother with XMPP ? Phoenix uses websockets which are working great for me sofar.

Ejabberd felt like something ‘meant for’ chat application and I am completely unaware about why or why not to use it instead of simple phoenix app.

derek-zhou

derek-zhou

Ejabberd or XMPP in general is meant for an industrial strength chat application with a rich and extensible set of functionalities, on a federated network governed by multiple entities. You may or may not need that.

Using Phoenix Liveview one put together a simple chat application quickly. I have one too:

I do not even use PubSub/Presence. There is more than one way to do it

TwistingTwists

TwistingTwists OP

What is a good indication that one needs to use ejabberd and it gives some clear benefits to other approaches ?

hauleth

hauleth

When you need protocol (because you want to exchange messages with systems that are out of your control) go with ejabberd. If you want internal system communication then Phoenix.PubSub is a solution.

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
thiagogsr
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews