简体   繁体   中英

Exception when running Cowboy start_listener()

I have followed http://maplekeycompany.blogspot.in/2012/03/very-basic-cowboy-setup.html link, but when I run this project it shows me crash report which tell that cowboy start_listener() is undefined.

=CRASH REPORT==== 12-Aug-2014::10:08:06 ===
  crasher:
    initial call: simple_server_http:init/1
    pid: <0.66.0>
    registered_name: []
    exception exit: {undef,
                     [{cowboy,start_listener,
                       [http,16,cowboy_tcp_transport,
                        [{port,8082}],
                        cowboy_http_protocol,
                        [{dispatch,
                          [{'_',
                            [{[],simple_server_http_static,
                              [<<"html">>,<<"index.html">>]},
                             {'_',simple_server_http_catchall,[]}]}]}]],
                       []},
                      {simple_server_http,init,1,
                       [{file,"src/simple_server_http.erl"},{line,45}]},
                      {gen_server,init_it,6,
                       [{file,"gen_server.erl"},{line,306}]},
                      {proc_lib,init_p_do_apply,3,
                       [{file,"proc_lib.erl"},{line,239}]}]}
      in function  gen_server:init_it/6 (gen_server.erl, line 330)
    ancestors: [simple_server_sup,<0.64.0>]
    messages: []
    links: [<0.65.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 610
    stack_size: 27
    reductions: 913
  neighbours:

=SUPERVISOR REPORT==== 12-Aug-2014::10:08:06 ===
     Supervisor: {local,simple_server_sup}
     Context:    start_error
     Reason:     {undef,
                  [{cowboy,start_listener,
                    [http,16,cowboy_tcp_transport,
                     [{port,8082}],
                     cowboy_http_protocol,
                     [{dispatch,
                       [{'_',
                         [{[],simple_server_http_static,
                           [<<"html">>,<<"index.html">>]},
                          {'_',simple_server_http_catchall,[]}]}]}]],
                    []},
                   {simple_server_http,init,1,
                    [{file,"src/simple_server_http.erl"},{line,45}]},
                   {gen_server,init_it,6,[{file,"gen_server.erl"},{line,306}]},
                   {proc_lib,init_p_do_apply,3,
                    [{file,"proc_lib.erl"},{line,239}]}]}
     Offender:   [{pid,undefined},
                  {name,simple_server_http},
                  {mfargs,{simple_server_http,start_link,[]}},
                  {restart_type,permanent},
                  {shutdown,5000},
                  {child_type,worker}]

what this error means and how to solve it?

This error message says that the function cowboy:start_listener/6 called by the module simple_server_http at line 45 does not exists. I have checked on github the code source of the cowboy module, this function does not exist, really. So the code from the blog has no chance to run with the current version of cowboy.

As it specify to use the erlang version R15B which is outdated (december 2011), maybe you could look at former version of cowboy: the version 0.6.0 was providing this function --> get the source from github .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM