2013-12-08 88 views
0

我試圖使這個應用FIX protocol二郎:與牧場

我開始使用erl -pa ./ebin -pa ebin ./deps/*/ebin Erlang的外殼連接錯誤的誤解。 然後像這樣運行應用程序:application:start(fix)。 之後,我調用這樣的「start_listener」函數:fix:start_listener()。 因此出現此錯誤:

exception error: no match of right hand side value 
       {error, 
        {{shutdown, 
          {failed_to_start_child,ranch_acceptors_sup, 
           badarg}}, 
         {child,undefined, 
          {ranch_listener_sup,fix_listener}, 
          {ranch_listener_sup,start_link, 
           [fix_listener,10,ranch_tcp, 
           [{port,[8501]}], 
           fix_server,[]]}, 
          permanent,5000,supervisor, 
          [ranch_listener_sup]}}} 
in function fix:start_listener/0 (src/fix.erl, line 21) 

這是什麼意思?以及如何解決這個錯誤?

我的代碼是:

`-module(fix). 
-author('Max Lapshin <[email protected]>'). 
-include("log.hrl"). 
    % -include("../include/admin.hrl"). 
-include("../include/business.hrl"). 
-compile(export_all). 

    %% @doc Start acceptor with `ranch' on port, specified in application environment under fix_port%% 
    -spec start_listener() -> {ok, pid()}. 
    start_listener() -> 
    application:start(ranch), 
    Spec = ranch:child_spec(fix_listener, 10, 
    ranch_tcp, [{port, fix:get_value(fix_port)}], 
    fix_server, [] 
    ), 
    {ok, Pid} = supervisor:start_child(fix_sup, Spec), 
     error_logger:info_msg("Starting FIX server on port ~p~n",[fix:get_value(fix_port)]), 
     {ok, Pid}. 

` 這是一段代碼,顯示一個錯誤。

+0

請顯示您的代碼。 –

回答

4

這是不正確的:

[{port,[8501]}] 

端口值必須是整數。 您的修正:get_value函數返回列表[8501]而不是8501,並且您得到這個badarg錯誤。

+0

感謝您的關注。我自己發現了錯誤,當我運行Erlang shell時,「ebin」很奇怪。 erl -pa ./ebin -pa ./deps/*/ebin這是正確的運行方式。 – user3079158