2017-08-06 20 views
0

我使用erlang客戶端庫使用默認連接參數連接到本地rabbitmq服務器。我在24小時內收到一次這個問題。我的Erlang應用程序無法處理此問題。 對於我的錯誤日誌我得到這些消息..如何處理erlang中的Rabbitmq錯誤shortstr_size?

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客戶端Acceptor的牧場。我的客戶端處理程序是一個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 

回答

1

你運行了out of file descriptors這意味着你打開太多的資源而不關閉它們(最有可能的連接)。

您可以增加您的file descriptors,但您需要監視您的客戶端並檢查它正在使用的資源。

注意您正在使用的客戶端有點舊,官方amqp rabbitmq客戶端是在十六進制存儲庫。 (https://hex.pm/packages/amqp_client) 您應該使用它在你的項目中:

{amqp_client, "3.6.10"}

+0

感謝您指出,我發現我不關閉RabbitMQ的連接,同時退出。現在,如果打開,我正在使用terminate方法正確關閉它們。 – rajesh6115