I am using erlang client library to connect to local rabbitmq server using default connection parameters. I am getting this issue in a span of arroung Once in 24 Hours. My Erlang Application Not Able to Handle This Issue. For My Error Logger I Getting These Message..
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
I am using this Library https://github.com/jbrisbin/amqp_client as it having rebar. And I am using rebar for my project .
May Be I written some thing wrong, As I am very new to erlang. And this is my First project Live in Erlang. I am using ranch as tcp client Acceptor. And My Client Handler is a gen_fsm.
code snipet what I am using
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}).
Also when ever I am getting this Issue My ranch socket Listener throwing below errors.
<0.815.0> Ranch acceptor reducing accept rate: out of file descriptors
you ran out of file descriptors
it means that you are opening too much resource without close them (Most likely connections).
you can increase your file descriptors, but you need to monitor your client and check the resources it is using.
NOTE the client you are using is a bit old, the official amqp rabbitmq client is on hex repository. (https://hex.pm/packages/amqp_client) You should use it on your project:
{amqp_client, "3.6.10"}