Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phoenix/Elixir/Ejabberd - Response already sent error

I was following this guide for embedding Ejabberd into a Phoenix application (https://blog.process-one.net/embedding-ejabberd-into-an-elixir-phoenix-web-application/) and I'm having an error now that it' running.

Basically, everything appears to work fine until I navigate to "http://localhost:4000/ejabberd" at which point I get the following error:

[error] #PID<0.721.0> running EjbrdTest.Endpoint terminated Server: localhost:4000 (http) Request: GET /ejabberd ** (exit) an exception was raised: ** (Plug.Conn.AlreadySentError) the response was already sent (plug) lib/plug/conn.ex:428: Plug.Conn.resp/3 (plug) lib/plug/conn.ex:415: Plug.Conn.send_resp/3 (ejbrdTest) web/controllers/ejabberd_controller.ex:1: EjbrdTest.EjabberdController.phoenix_controller_pipeline/2 (ejbrdTest) lib/phoenix/router.ex:265: EjbrdTest.Router.dispatch/2 (ejbrdTest) web/router.ex:1: EjbrdTest.Router.do_call/2 (ejbrdTest) lib/ejbrdTest/endpoint.ex:1: EjbrdTest.Endpoint.phoenix_pipeline/1 (ejbrdTest) lib/plug/debugger.ex:90: EjbrdTest.Endpoint."call (overridable 3)"/2 (ejbrdTest) lib/phoenix/endpoint/render_errors.ex:34: EjbrdTest.Endpoint.call/2 (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4 (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

And rather than a list of users, I see this in the jumbotron:

Online users: < %= for user <- @users do %> < %= user %>

< % end %>

I've not been able to find anything on this, any ideas?

Thanks. Let me know if you need any more info.

like image 895
2 revs, 2 users 99% Avatar asked Sep 08 '15 02:09

2 revs, 2 users 99%


1 Answers

Removing plug :action will fix the issue. Looks like it is called by default now, so that line causes a duplicate error:

https://github.com/phoenixframework/phoenix/issues/888

like image 172
Everhusk Avatar answered Oct 02 '22 14:10

Everhusk