Search code examples
xmppejabberd

Routing to specific XEP-0114 instances backing a single domain in ejabberd?


I've got a simple ejabberd 18.09 setup running a test component under the domain: test.localhost.

The configuration is super simple:

port: 8888
module: ejabberd_service
hosts:
   "test.localhost":
       password: "secret"

I've got my XEP-0114 / XMPP component setup to run multiple instances via a Procfile:

test1: ./testcomponent --address localhost:8888 --secret ... --name test.localhost
test2: ./testcomponent --address localhost:8888 --secret ... --name test.localhost
test3: ./testcomponent --address localhost:8888 --secret ... --name test.localhost

Now when i send a message to any contact under test.localhost, one of these is guaranteed to get it. That's great! That seems like for any given xmpp component, you can scale out to multiple hosts and nodes without worrying about a single point of failure.

Is there a way to always route messages sent to user1@test.localhost to test1 process above? Maybe with a specific presence message sent by the test1 instance with user1@test.localhost as the contact?


Solution

  • You should use the option “domain_balancing” with value bare_source. It will ensure all packets from a given user gets to the same component. Documentation is here: https://docs.ejabberd.im/admin/guide/advanced/