Erlang:误解了与牧场有关的错误

时间:2013-12-08 05:49:52

标签: erlang

我正在尝试制作此应用FIX protocol

我使用erl -pa ./ebin -pa ebin ./deps/*/ebin启动Erlang shell。 并运行这样的应用程序: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 <max@maxidoors.ru>').
 -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}.

` 这是一段显示错误的代码。

1 个答案:

答案 0 :(得分:4)

这是不正确的:

[{port,[8501]}]

端口值必须是整数。 你的修复:get_value函数返回列表[8501]而不是8501,你得到这个 badarg 错误。