0

我正在使用 erlang 客户端库使用默认连接参数连接到本地 rabbitmq 服务器。我在 24 小时内遇到了这个问题。我的 Erlang 应用程序无法处理此问题。对于我的错误记录器,我收到这些消息..

2017-08-06 12:45:03.883 [error] <0.3739.0>@rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3739.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:03.883 [error] <0.3736.0> Supervisor {<0.3736.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2798>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3738.0>, {<<"client 127.0.0.1:56646 -> 127.0.0.1:5672">>,1}) at <0.3739.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:03.900 [error] <0.3736.0> Supervisor {<0.3736.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2798>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3738.0>, {<<"client 127.0.0.1:56646 -> 127.0.0.1:5672">>,1}) at <0.3739.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:04.514 [error] <0.3754.0>@rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3754.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:04.514 [error] <0.3751.0> Supervisor {<0.3751.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2819>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3753.0>, {<<"client 127.0.0.1:49559 -> 127.0.0.1:5672">>,1}) at <0.3754.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:04.515 [error] <0.3751.0> Supervisor {<0.3751.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2819>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3753.0>, {<<"client 127.0.0.1:49559 -> 127.0.0.1:5672">>,1}) at <0.3754.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:04.846 [error] <0.3768.0>@rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3768.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:04.846 [error] <0.3765.0> Supervisor {<0.3765.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2821>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3767.0>, {<<"client 127.0.0.1:60413 -> 127.0.0.1:5672">>,1}) at <0.3768.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:04.846 [error] <0.3765.0> Supervisor {<0.3765.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2821>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3767.0>, {<<"client 127.0.0.1:60413 -> 127.0.0.1:5672">>,1}) at <0.3768.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:05.154 [error] <0.3782.0>@rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3782.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:05.154 [error] <0.3779.0> Supervisor {<0.3779.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2823>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3781.0>, {<<"client 127.0.0.1:36301 -> 127.0.0.1:5672">>,1}) at <0.3782.0> exit with reason badarg in context child_terminated
2017-08-06 12:45:05.154 [error] <0.3779.0> Supervisor {<0.3779.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2823>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3781.0>, {<<"client 127.0.0.1:36301 -> 127.0.0.1:5672">>,1}) at <0.3782.0> exit with reason reached_max_restart_intensity in context shutdown
2017-08-06 12:45:05.484 [error] <0.3796.0>@rabbit_framing_amqp_0_9_1:shortstr_size:210 CRASH REPORT Process <0.3796.0> with 0 neighbours crashed with reason: bad argument in call to erlang:size([]) in rabbit_framing_amqp_0_9_1:shortstr_size/1 line 210
2017-08-06 12:45:05.484 [error] <0.3793.0> Supervisor {<0.3793.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2825>, 1, 131072, rabbit_framing_amqp_0_9_1, <0.3795.0>, {<<"client 127.0.0.1:34055 -> 127.0.0.1:5672">>,1}) at <0.3796.0> exit with reason badarg in context child_terminated

我正在使用这个库 https://github.com/jbrisbin/amqp_client 因为它有钢筋。我正在为我的项目使用钢筋。

可能是我写错了一些东西,因为我对 erlang 很陌生。这是我在 Erlang 中的第一个项目。我使用牧场作为 tcp 客户端接受器。我的客户端处理程序是一个 gen_fsm。

我正在使用的代码片段

init({Ref, Socket, Transport, Mod, _Opts=[]})->
        process_flag(trap_exit, true),
        ok = ranch:accept_ack(Ref),
        ok = Transport:setopts(Socket, [{active, once}]),
        {ok, {RemoteIp, _Port}} = inet:peername(Socket),
        lager:info("New Client Connection From ~w Socket ~w", [RemoteIp, Socket]),
        {ok, RabbitConnection} = amqp_connection:start(#amqp_params_network{}),
        {ok, RabbitChannel} = amqp_connection:open_channel(RabbitConnection),
        InitTimerRef = erlang:start_timer(30000, self(), session_init_timer_laps),
        gen_fsm:enter_loop(?MODULE, [], open, #state{socket=Socket, transport=Transport, buffer= <<>>, mod=Mod, timers=#session_timers{session_init_timer=InitTimerRef}, sequence_number=1, rabbitmq_conn=RabbitConnection, rabbitmq_channel=RabbitChannel, remote_ip=RemoteIp}).

另外,当我遇到此问题时,我的牧场套接字侦听器会抛出错误。

<0.815.0> Ranch acceptor reducing accept rate: out of file descriptors
4

1 回答 1

1

您运行 out of file descriptors它意味着您在没有关闭它们的情况下打开了太多资源(很可能是连接)。

你可以增加你的文件描述符,但你需要监控你的客户端并检查它正在使用的资源。

注意您使用的客户端有点旧,官方的 amqp rabbitmq 客户端位于 hex 存储库中。( https://hex.pm/packages/amqp_client ) 你应该在你的项目中使用它:

{amqp_client, "3.6.10"}

于 2017-08-06T13:27:29.597 回答