简体   繁体   English

Erlang:与牧场相关的错误的误解

[英]Erlang: misunderstanding of an error that is connected with ranch

I am trying to make this application FIX protocol 我正在尝试使此应用程序FIX协议

I start the Erlang shell using erl -pa ./ebin -pa ebin ./deps/*/ebin . 我使用erl -pa ./ebin -pa ebin ./deps/*/ebin启动Erlang Shell。 And run the application like this: application:start(fix) . 然后像这样运行应用程序: application:start(fix) After that I invoke "start_listener" function like this: fix:start_listener() . 之后,我像这样调用“ start_listener”函数: fix:start_listener() As a result this mistake appears: 结果,此错误出现:

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)

What does it all mean? 这是什么意思呢? And how to fix this mistake? 以及如何解决这个错误?

My code is: 我的代码是:

`-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}.

` This is a piece of code that shows a mistake. `这是一段显示错误的代码。

This is incorrect: 这是不正确的:

[{port,[8501]}]

Port value must be an integer. 端口值必须是整数。 Your fix:get_value function returns list [8501] instead 8501 and you get this badarg error. 您的fix:get_value函数返回列表[8501]而不是8501,您会收到此badarg错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM