jlouis / turtle

A wrapper on the RabbitMQ Erlang Client (Erlang)
Other
71 stars 15 forks source link

Non-binary payload in publishing functions crashes publisher #17

Closed ptrf closed 7 years ago

ptrf commented 8 years ago

I have a simple publisher set up with:

init([]) ->
    Procs = [turtle_publisher:child_spec(my_publisher, 
                                         amqp_server,
                                         [],
                                         #{ confirms => true,
                                            passive => false })
             ],
    {ok, { {one_for_one, 10, 60}, Procs} }.

When invoking turtle:publish(my_publisher, <<"SomeExchange">>, <<"routing.key">>, <<"text/plain">>, "asdb"), the publisher client crashes. The full output is here:

15:55:07.852 [error] Supervisor {<0.887.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2183>, 2, 131072, rabbit_framing_amqp_0_9_1, <0.889.0>, {<<"client 127.0.0.1:61547 -> 127.0.0.1:5672">>,2}) at <0.890.0> exit with reason bad argument in call to erlang:size(98) in rabbit_binary_generator:build_content_frames/7 line 98 in context child_terminated
15:55:07.852 [error] Error in process <0.890.0> on node 'test@127.0.0.1' with exit value:
{badarg,[{erlang,size,"b",[]},{rabbit_binary_generator,build_content_frames,7,[{file,"/Users/ptrf/Work/test/_build/default/lib/rabbit_common/src/rabbit_binary_generator.erl"},{line,98}]},{rabbit_binary_generator,build_simple_content_frames,4,[{file,"/Users/ptrf/Work/test/_build/default/lib/rabbit_common/src/rabbit_binary_generator.erl"},{line,73}]},{rabbit_writer,assemble_frames,5,[{file,"/Users/ptrf/Work/test/_build/default/lib/rabbit_common/src/rabbit_writer.erl"},{line,312}]},{rabbit_writer,internal_send_command_async,3,[{file,"/Users/ptrf/Work/test/_build/default/lib/rabbit_common/src/rabbit_writer.erl"},{line,342}]},{rabbit_writer,handle_message,3,[{file,"/Users/ptrf/Work/test/_build/default/lib/rabbit_common/src/rabbit_writer.erl"},{line,210}]},{rabbit_writer,mainloop1,2,[{file,"/Users/ptrf/Work/test/_build/default/lib/rabbit_common/src/rabbit_writer.erl"},{line,194}]},{rabbit_writer,mainloop,2,[{file,"/Users/ptrf/Work/test/_build/default/lib/rabbit_common/src/rabbit_writer.erl"},{line,185}]}]}
15:55:07.877 [error] Supervisor {<0.887.0>,amqp_channel_sup} had child writer started with rabbit_writer:start_link(#Port<0.2183>, 2, 131072, rabbit_framing_amqp_0_9_1, <0.889.0>, {<<"client 127.0.0.1:61547 -> 127.0.0.1:5672">>,2}) at <0.890.0> exit with reason reached_max_restart_intensity in context shutdown
15:55:07.877 [error] gen_server <0.866.0> terminated with reason: {error,{channel_down,shutdown}}
15:55:07.877 [error] CRASH REPORT Process <0.866.0> with 0 neighbours exited with reason: {error,{channel_down,shutdown}} in gen_server:terminate/7 line 826
15:55:07.878 [error] Supervisor test_sup had child my_publisher started with turtle_publisher:start_link(my_publisher, amqp_server, [], #{confirms => true, passive => false}) at <0.866.0> exit with reason {error,{channel_down,shutdown}} in context child_terminated

The same happens when Payload = ["asdb"]. With Payload = <<"asdb">>, it works.