walkerbrown

walkerbrown

Embedding ejabberd in a Phoenix app

If you’re working to embed ejabberd into a Phoenix app, I hope this helps!

I had been following the docs and tutorial (note that the blog post is dated):
https://docs.ejabberd.im/developer/extending-ejabberd/elixir/
https://blog.process-one.net/embedding-ejabberd-into-an-elixir-phoenix-web-application/

I’m using the following versions:

  • Phoenix 1.4.10
  • ejabberd 19.8

If you’re having Logger/logger/lager issues, see this related thread: https://forum.elixirforum.com/t/getting-ejabberd-to-use-elixir-logger-in-release-build/24252

I had been getting an error on compilation (see below). The solution was to remove the ejabberd dependency from mix.exs, clean out the build, get and compile the other dependencies, then add back ejabberd before a final compilation step. Here’s the full workaround:

# Clean out build; careful with rm -rf ...
rm -rf _build
rm -rf deps
mix deps.clean --all
# In mix.exs, comment out the line in deps {:ejabberd, "~> 19.8"},
mix do deps.get, compile
# In mix.exs, uncomment the ejabberd line in deps
mix do deps.get, compile

Does anyone know why building everything at once causes this task to crash? I’d like to find a better solution. Thanks!

...
==> phoenix_ecto
Compiling 6 files (.ex)
Generated phoenix_ecto app

16:32:04.624 [info]  Application phoenix exited: exited in: Phoenix.start(:normal, [])
    ** (EXIT) exited in: :gen_server.call(:telemetry_handler_table, {:insert, {Phoenix.Logger, [:phoenix, :channel_handled_in]}, [[:phoenix, :channel_handled_in]], #Function<8.17735610/4 in Phoenix.Logger.install/0>, :ok})
        ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

16:32:04.624 [info]  Application eex exited: :stopped
** (MatchError) no match of right hand side value: {:error, {:phoenix, {:bad_return, {{Phoenix, :start, [:normal, []]}, {:EXIT, {:noproc, {:gen_server, :call, [:telemetry_handler_table, {:insert, {Phoenix.Logger, [:phoenix, :channel_handled_in]}, [[:phoenix, :channel_handled_in]], #Function<8.17735610/4 in Phoenix.Logger.install/0>, :ok}]}}}}}}}
    (phoenix) lib/mix/tasks/compile.phoenix.ex:11: Mix.Tasks.Compile.Phoenix.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/compile.all.ex:73: Mix.Tasks.Compile.All.run_compiler/2
    (mix) lib/mix/tasks/compile.all.ex:53: Mix.Tasks.Compile.All.do_compile/4
    (mix) lib/mix/tasks/compile.all.ex:24: anonymous fn/1 in Mix.Tasks.Compile.All.run/1
    (mix) lib/mix/tasks/compile.all.ex:40: Mix.Tasks.Compile.All.with_logger_app/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/tasks/compile.ex:96: Mix.Tasks.Compile.run/1
    (mix) lib/mix/task.ex:331: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:79: Mix.CLI.run_task/2
    (elixir) lib/code.ex:813: Code.require_file/2

In any case, I hope this workaround helps someone out there!

First Post! Switch mode

— All posts loaded —

Where Next?

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement