Closed Shakarim closed 4 years ago
When you start it in port 7001 and it works, is it still running on port 7000? --
José Valim www.plataformatec.com.br Founder and Director of R&D
Yeap. Both of em works correctly. Moreover, when I run third, fourth and etc. It's still show me errors, but all of em works.
So the error is a bit misleading but it is common from Cowboy side, so we will do a report upstream. But in a nutshell, the issue is that you are using the same name for every adapter.
This should fix it:
def start_server(port) do
DynamicSupervisor.start_child(Master.DynamicSupervisor,{
Plug.Cowboy,
scheme: :http,
plug: Router,
options: [
port: port,
ref: make_ref()
]
})
end
Problem solved, thank you very much
Description I'm not sure it's bug or not, but I observe a strange behavior of server. I face with the task of starting two or more supervised http server with different ports, and I did the following:
I've created simple mix application with supervised DynamicSupervisor
This module contain just one custom function, it's
Master.start_server/1
, it receive the port as argument, and trying to start PlugCowboy with this port as child of DynamicSupervisors.I've added a simple router with "/echo"
And have tried to start it via
iex -S mix
What I've got I've got
So far so good. And now, I'm trying to start my first server:
Still okay, but, if I try to run a second server on another port:
I got this:
What's strange?
**All log of my console***