erlangerlang-otpcowboyrebar3

Error during starting the application with cowboy example ('noproc', ranch_listener_sup)


I'm trying run this cowboy example using rebar3: cowboy version 2.0.0-pre.5

What I do is:

  1. rebar3 new app hello_world
  2. copy the example src into my src
  3. updating rebar.config {cowboy,".*", {git, "https://github.com/ninenines/cowboy", {branch, "master"}}}
  4. rebar3 compile. Everything go fine
  5. erl -pa _build/default/lib/*/ebin
  6. application:start(hello_world).

then error occurs

{error,{bad_return,{{hello_world_app,start,[normal,[]]},
                    {'EXIT',{noproc,{gen_server,call,
                                                [ranch_sup,
                                                 {start_child,{{ranch_listener_sup,http},
                                                               {ranch_listener_sup,start_link,
                                                                                   [http,100,ranch_tcp,
                                                                                    [{connection_type,supervisor},{port,...}],
                                                                                    cowboy_clear,
                                                                                    #{connection_type => supervisor,...}]},
                                                               permanent,infinity,supervisor,
                                                               [ranch_listener_sup]}},
                                                 infinity]}}}}}}

=INFO REPORT==== 24-Jan-2017::18:34:52 ===
    application: hello_world
    exited: {bad_return,
                {{hello_world_app,start,[normal,[]]},
                 {'EXIT',
                     {noproc,
                         {gen_server,call,
                             [ranch_sup,
                              {start_child,
                                  {{ranch_listener_sup,http},
                                   {ranch_listener_sup,start_link,
                                       [http,100,ranch_tcp,
                                        [{connection_type,supervisor},
                                         {port,8080}],
                                        cowboy_clear,
                                        #{connection_type => supervisor,
                                          env => #{dispatch => [{'_',[],
                                                 [{[],[],toppage_handler,
                                                   []}]}]}}]},
                                   permanent,infinity,supervisor,
                                   [ranch_listener_sup]}},
                              infinity]}}}}}
    type: temporary

It seems that runch_sup can't start. What's wrong with my approach? I want to run exactly the same src code as in example.


Solution

  • Ranch 1.3 depends on the ssl application by default. If you don't start it, Ranch fails to start. I would recommend matching on ok when doing ok = application:start(App), you'd have known the issue much quicker.

    by essen

    here is the issue