I'm having trouble deciphering this error message that I'm getting when hitting a simple endpoint created with Cowboy. I created a simple app with cowboy (https://github.com/overture8/cow_app) then started the app using rebar3 shell
(not sure if this is correct?). Anyway, I'm getting this error when hitting the endpoint:
Error in process <0.232.0> with exit value:
{[{reason,undef},
{mfa,{hello_handler,init,3}},
{stacktrace,
[{hello_handler,init,
[{tcp,http},
{http_req,#Port<0.7138>,ranch_tcp,keepalive,<0.232.0>,<<"GET">>,
'HTTP/1.1',
{{127,0,0,1},49651},
<<"127.0.0.1">>,undefined,8010,<<"/">>,undefined,<<>>,
undefined,[],
[{<<"host">>,<<"127.0.0.1:8010">>},
{<<"connection">>,<<"keep-alive">>},
{<<"cache-control">>,<<"max-age=0">>},
{<<"upgrade-insecure-requests">>,<<"1">>},
{<<"user-agent">>,
<<"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36">>},
{<<"accept">>,
<<"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8">>},
{<<"dnt">>,<<"1">>},
{<<"accept-encoding">>,<<"gzip, deflate, sdch">>},
{<<"accept-language">>,
<<"en-GB,en;q=0.8,en-US;q=0.6,fr;q=0.4">>}],
[{<<"connection">>,[<<"keep-alive">>]}],
undefined,[],waiting,<<>>,undefined,false,waiting,[],<<>>,
undefined},
[]],
[]},
.
.
.
Maybe I'm just doing something completely wrong - this is my first experience with using Erlang.
Any help would be greatly appreciated.
Your rebar.lock
is out of sync with rebar.config
and is pointing to version 1.0.1 of cowboy which requires init/3
to be exported, not init/2
, which is what the error ... {reason,undef}, {mfa,{hello_handler,init,3}}, ...
means.
To fix, run rebar3 upgrade cowboy
and then run rebar3 shell
. After I run that, the application works fine for me:
$ curl -i http://localhost:8010/
HTTP/1.1 200 OK
server: Cowboy
date: Wed, 07 Sep 2016 09:57:22 GMT
content-length: 13
content-type: text/plain
Hello Erlang!