Heads up: the ranch child spec opts might need to be reworked
voughtdq opened this issue · comments
I'm on ranch 1.5, so this might not be applicable to you.
I'm using Plug.Cowboy with a Phoenix project and can't confirm if this is caused by Phoenix, Plug.Cowboy, or my own local configuration. Phoenix on master and Plug.Cowboy on master.
-
Ranch expects the transport opts to be a proplist. They are currently being passed as a map.
-
After reworking plug_cowboy locally to convert the transport opts
%{max_connections: 16384, num_acceptors: 100, socket_opts: [port: 4000]}
to a Keyword list/proplist, I was getting a:badarg
exception. I'm not sure wheresocket_opts
is coming from (maybe Phoenix?), but I pulled the port config out of socket opts and was able to start without crashing.
Here is the specific exception in question:
[info] Application administration exited: Administration.Application.start(:normal, []) returned an error: shutdown: failed to start child: AdministrationWeb.Endpoint
** (EXIT) an exception was raised:
** (FunctionClauseError) no function clause matching in :proplists.get_value/3
(stdlib) proplists.erl:215: :proplists.get_value(:num_acceptors, %{max_connections: 16384, num_acceptors: 100, socket_opts: [port: 4000]}, 10)
(ranch) /data/repos/turret/deps/ranch/src/ranch.erl:116: :ranch.child_spec/5
(plug_cowboy) lib/plug/cowboy.ex:185: Plug.Cowboy.child_spec/1
(phoenix) lib/phoenix/endpoint/cowboy2_adapter.ex:44: Phoenix.Endpoint.Cowboy2Adapter.child_spec/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:106: anonymous fn/6 in Phoenix.Endpoint.Supervisor.server_children/4
(elixir) lib/enum.ex:1925: Enum."-reduce/3-lists^foldl/2-0-"/3
(phoenix) lib/phoenix/endpoint/supervisor.ex:97: Phoenix.Endpoint.Supervisor.server_children/4
(phoenix) lib/phoenix/endpoint/supervisor.ex:57: Phoenix.Endpoint.Supervisor.init/1
(stdlib) supervisor.erl:295: :supervisor.init/1
(stdlib) gen_server.erl:374: :gen_server.init_it/2
(stdlib) gen_server.erl:342: :gen_server.init_it/6
(stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Can you please let us know exactly which arguments you are passing here?
Btw, please note that Ranch v1.6 has migrated to a map: https://ninenines.eu/docs/en/ranch/1.6/manual/ranch/ - which this project uses.
I changed the arguments to [port: 4000, num_acceptors: 100]
and that fixed the problem,
The real problem seems to be that I'm using Ranch 1.5 which I need because another library I have depends on cowlib 2.4. I'll go ahead and close this.