2016-09-07 104 views
0

我無法破譯這個錯誤消息,當我點擊使用Cowboy創建的簡單終端時,我得到了這個錯誤消息。我用牛仔創建了一個簡單的應用程序(https://github.com/overture8/cow_app),然後使用rebar3 shell啓動應用程序(不知道這是否正確?)。無論如何,我打的端點時收到此錯誤:使用Erlang Cowboy應用程序獲得500響應

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的第一次經歷。

任何幫助將不勝感激。

+0

忘了提及 - 我使用Mac並使用'brew install erlang'安裝了Erlang。我安裝的版本是「Erlang/OTP 19 [erts-8.0.2]」。 – overture8

回答

1

rebar.lock是不同步rebar.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! 
+0

非常感謝您的關注!現在工作。 – overture8