Setting Up ejabberd for XEP-0389 Implementation

Quickly reminder

As part of my Google Summer of Code (GSoC) project, I embarked on the journey of implementing XEP-0389 in ejabberd. This blog post details the process of setting up ejabberd, the challenges I encountered, and how I overcame them. I aim to provide a comprehensive guide for developers, especially those new to ejabberd and XMPP.

Setting Up ejabberd

1. Installation:

2. Configuration: (Optional)

3. Port Configuration:

Overcoming Challenges

1. Module Loading Issues:

$ ejabberdctl debug

genmod:loadedmodules(<<“localhost”>>). [modadhoc,modping,modmam,modannounce,mod_offline, ...

genmod:isloaded(<<“localhost”>>, mod_ping). true you can also check any erlang beam file, not only ejabberd modules:

code:isloaded(modping). {file,“/home/badlop/git/ejabberd/build/dev/lib/ejabberd/ebin/modping.beam”}

code:isloaded(ejabberdsm). {file,“/home/badlop/git/ejabberd/build/dev/lib/ejabberd/ebin/ejabberdsm.beam”}

code:is_loaded(mnesia). {file,“/home/badlop/.asdf/installs/erlang/27.0/lib/mnesia-4.23.2/ebin/mnesia.beam”}`

Also I ensured the ejabberd service user had the necessary permissions: sh sudo chown -R assu_2000:ejabberd /usr/local/var/lib/ejabberd sudo chmod -R 750 /usr/local/var/lib/ejabberd

2. Database Configuration:

3. TLS and Connection Issues:

import ( “fmt” “log” “os”

“github.com/xmppo/go-xmpp” )

func main() { jid := os.Getenv(“JID”) password := os.Getenv(“PASSWORD”) host := os.Getenv(“HOST”)

if jid == “” || password == “” || host == “” { log.Fatal(“Usage: JID, PASSWORD and HOST must be set as environment variables”) }

options := xmpp.Options{ Host: host, User: jid, Password: password, NoTLS: true, StartTLS: false, Debug: true, InsecureAllowUnencryptedAuth: true, Session: true, Status: “available”, StatusMessage: “Welcome on our new codebot overlords.”, Resource: “xmppconsole”, }

talk, err := options.NewClient() if err != nil { log.Fatalf(“Failed to create XMPP client: %v”, err) }

fmt.Println(“Connected to XMPP server.”) for { chat, err := talk.Recv() if err != nil { log.Fatal(err) } switch v := chat.(type) { case xmpp.Chat: fmt.Printf(“Received message from %s: %s\n”, v.Remote, v.Text) case xmpp.Presence: fmt.Printf(“Received presence from %s\n”, v.From) } } }

`

4. Hostname and Hosts File Configuration:

Using ejabberdctl

Instead of using systemctl, I decided to use ejabberdctl to manage the ejabberd server. Here are some useful commands:

Setting Up xmppconsole

xmppconsole has the unique purpose of testing. To execute it , you need it installed alongside Python3 or Go. I chose to go with Go :) By the way, xmppconsole has only 1 required dependency: libstrophe version 0.10.0 or higher This is where the main.go file plays a key role .

1. Installation and Configuration:

2. Configuring main.go:

3. Running xmppconsole:

`

Using xmppconsole

Once connected, I could send messages and manage presence using xmppconsole. Here are a few examples:

*Send a Message: sh message recipient@localhost "Hello, this is a test message"

*Set Presence: sh presence

Conclusion

Setting up ejabberd for XEP-0389 implementation involved configuring the server, addressing module loading issues, managing database settings, and overcoming connection problems with xmppconsole. This detailed journey highlights the common challenges and solutions, providing a guide for developers embarking on similar projects.

For more detailed information and troubleshooting, refer to the ejabberd and XMPP documentation and the ejabberd xmpp community group as well. Happy coding!


P.S : This blog post provides a comprehensive overview of my experience setting up ejabberd and troubleshooting various issues. By following this guide, other developers should be able to set up their environments more smoothly and focus on implementing new features other to XEP-0389.

I'd love to hear from you! If you're struggling with XMPP implementation or have any questions, feel free to reach out. I'm always happy to help a fellow coder out.

Github Profile : Link

Thanks for reading !