【问题标题】:Getting 500 response with Erlang Cowboy app使用 Erlang Cowboy 应用程序获得 500 响应
【发布时间】:2017-01-14 20:25:15
【问题描述】:

我无法解读在访问使用 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。

任何帮助将不胜感激。

【问题讨论】:

  • 忘了提及 - 我使用的是 Mac 并使用 brew install erlang 安装了 Erlang。我安装的版本是“Erlang/OTP 19 [erts-8.0.2]”。

标签: erlang cowboy rebar3


【解决方案1】:

您的rebar.lockrebar.config 不同步,并且指向需要导出init/3 的牛仔版本1.0.1,而不是init/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!

【讨论】:

  • 非常感谢您的关注!现在工作。
猜你喜欢
  • 1970-01-01
  • 2021-03-26
  • 2016-01-23
  • 1970-01-01
  • 1970-01-01
  • 2021-05-05
  • 2011-09-18
  • 2012-10-13
  • 1970-01-01
相关资源
最近更新 更多