Reputation: 4701
I'm trying to create a Phoenix umbrella project with several apps on the same port. With my current config I receive this error:
⧕ /m/i/d/p/e/portfolio on master * ⟩mix phoenix.server 13m 20s 412ms
==> rumbl
Compiling 17 files (.ex)
Generated rumbl app
[info] Running Rumbl.Endpoint with Cowboy using http://localhost:8080
[error] Failed to start Ranch listener Persona.Endpoint.HTTP in :ranch_tcp:listen([port: 8080]) for reason :eaddrinuse (address already in use)
[info] Application persona exited: Persona.start(:normal, []) returned an error: shutdown: failed to start child: Persona.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, Persona.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, Persona.Endpoint.HTTP, :eaddrinuse}
** (Mix) Could not start application persona: Persona.start(:normal, []) returned an error: shutdown: failed to start child: Persona.Endpoint
** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, Persona.Endpoint.HTTP}
** (EXIT) shutdown: failed to start child: :ranch_acceptors_sup
** (EXIT) {:listen_error, Persona.Endpoint.HTTP, :eaddrinuse}
The details of my umbrella project are that I currently have 3 apps. 1 app proxies requests to the other 2 apps. The proxy app is a basic plug app.
# /apps/proxy/lib/proxy/plug.ex
...
def call(conn, _opts) do
cond do
conn.host =~ ~r{rumbl.} ->
Rumbl.Endpoint.call(conn, [])
true ->
Persona.Endpoint.call(conn, [])
end
end
...
Persona app
# /apps/persona/config/dev.exs
...
config :persona, Persona.Endpoint,
http: [port: 8080],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
cd: Path.expand("../", __DIR__)]]
...
Rumbl.app
# /apps/rumbl/config/dev.exs
config :rumbl, Rumbl.Endpoint,
http: [port: 8080],
debug_errors: true,
code_reloader: true,
check_origin: false,
watchers: [node: ["node_modules/brunch/bin/brunch", "watch", "--stdin",
cd: Path.expand("../", __DIR__)]]
My requirement is because I'm using nanabox.io for my development and deployment and it requires that all http/https be received on port 8080.
Upvotes: 0
Views: 978
Reputation: 703
If your proxy endpoint receives all the traffic anyway, set the port of the other 2 to something random so the ports don't collide.
Upvotes: 2