0

在访问使用 Cowboy 创建的简单端点时,我无法解读此错误消息。我用牛仔( https://github.com/overture8/cow_app )创建了一个简单的应用程序,然后使用rebar3 shell(不确定这是否正确?)启动了应用程序。无论如何,我在到达端点时遇到了这个错误:

    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},
                []],
               []},
                .
                .
                .

也许我只是在做一些完全错误的事情——这是我第一次使用 Erlang。

任何帮助将不胜感激。

4

1 回答 1

1

您与需要导出的牛仔版本 1.0.1 不rebar.lock同步,而不是,这就是错误的含义。rebar.configinit/3init/2... {reason,undef}, {mfa,{hello_handler,init,3}}, ...

要修复,运行rebar3 upgrade cowboy然后运行rebar3 shell​​. 在我运行它之后,该应用程序对我来说很好:

$ 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!
于 2016-09-07T10:01:18.570 回答