[英]Erlang: misunderstanding of an error that is connected with ranch
我正在尝试使此应用程序FIX协议
我使用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}.
`这是一段显示错误的代码。
这是不正确的:
[{port,[8501]}]
端口值必须是整数。 您的fix:get_value函数返回列表[8501]而不是8501,您会收到此badarg错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.