OTP / Cowboy2 Error

I tried to follow the example from here to get http version 2 running. The error belongs to Cowboy but I dont understand it and I think its because I know too little about the OTP.

I tried to use as key both handler or adapter keys in dev.exs

https: [port: 4000, keyfile: "priv/server.key", certfile: "priv/server.pem"],
adapter: Phoenix.Endpoint.Cowboy2Handler,

** (Mix) Could not start application thttps: Thttps.Application.start(:normal, []) returned an error: shutdown: failed to start child: ThttpsWeb.Endpoint
** (EXIT) an exception was raised:
 ** (UndefinedFunctionError) function Phoenix.Endpoint.Cowboy2Handler.child_spec/3 is undefined or private
(phoenix) Phoenix.Endpoint.Cowboy2Handler.child_spec(:https, ThttpsWeb.Endpoint, [port: 4000, otp_app: :thttps, keyfile: "priv/server.key", certfile: "priv/server.pem"])

Should that config key be handler: instead of adapter: ?

Edit: sorry just re-read where you say you already tried that.

Reading the phoenix source code, seems that they implemented the child_spec/3 a function for specifying supervisioned child’s arguments and initialization (I think it got introduced in Elixir 1.6) on Cowboy2Adapter.
So try to replace with:
adapter: Phoenix.Endpoint.Cowboy2Adapter instead of using the handler. Actually the adapter uses the handler inside.

1 Like

The lack of documentation and constant change is because the version that introduces Cowboy 2 support is still undergoing development. :slight_smile: