Phoenix/Elixir/Ejabberd - Response already sent error

試著忘記壹切 提交于 2019-12-01 15:03:14

问题


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.


回答1:


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




回答2:


The blog post had a rendering issue (now fixed). There is no space between < and %.

You can download the actual source code from Gist: https://gist.github.com/mremond/383666d563025e86adfe#file-index-html-eex



来源:https://stackoverflow.com/questions/32448308/phoenix-elixir-ejabberd-response-already-sent-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!