rabbitmq / rabbitmq-web-stomp

Provides support for STOMP over WebSockets
Other
89 stars 26 forks source link

case_clause error in rabbit_ws_client when a consumer is cancelled #75

Closed choyuri closed 7 years ago

choyuri commented 7 years ago

this looks like a simple function return mismatch

case clause expects a 2- tuple but the function call returns 3- tuple

rabbit_stomp_process:process_request returns 3-tuple

{ok, send_error(Message, Detail, NewState), Conn};

issue is present on rabbitmq_v3_6_9 release

** Reason for termination == 
** {{case_clause,
     {ok,
      {proc_state,"session-c6FVt0llvbYAOm5ZQl1lmQ",<0.1345.59>,<0.1334.59>,
       {dict,1,16,16,8,80,48,
        {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
        {{[],[],[],[],
          [[<<"T_GEN_40a78a81-f81d-4311-8de7-bc79a3a119348f598e4355667bb2f145a77bd4c68ae">>|
            {subscription,
             "/exchange/general.exch/40a78a81-f81d-4311-8de7-bc79a3a119348f598e4355667bb2f145a77bd4c68ae",
             auto,false,
             "id='GEN_40a78a81-f81d-4311-8de7-bc79a3a119348f598e4355667bb2f145a77bd4c68ae'"}]],
          [],[],[],[],[],[],[],[],[],[],[]}}},
       "1.2",undefined,undefined,
       {stomp_configuration,undefined,undefined,false,false,undefined},
       {set,0,16,16,8,80,48,
        {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
        {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}},
       {dict,0,16,16,8,80,48,
        {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
        {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}},
       #Fun<rabbit_stomp_processor.5.39359141>,
       {amqp_adapter_info,
        {10,0,101,158},
        15674,
        {10,0,141,178},
        35335,<<"10.0.141.178:35335 -> 10.0.101.158:15674">>,
        {'Web STOMP',0},
        [{channels,1},
         {channel_max,1},
         {frame_max,0},
       {client_properties,[{<<"product">>,longstr,<<"STOMP client">>}]},
         {state,running},
         {ssl,false}]},
       #Fun<rabbit_ws_client.0.99251689>,none,
       {10,0,141,178},
       true},
      <0.1334.59>}},
    [{rabbit_ws_client,handle_info,2,
      [{file,"src/rabbit_ws_client.erl"},{line,156}]},
     {gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,615}]},
     {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,681}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
michaelklishin commented 7 years ago

How can this be reproduced?

michaelklishin commented 7 years ago

Looks like a Web STOMP consumer has to be cancelled by the server. At first approximation the hypothesis of @choyuri seems correct: rabbit_stomp_processor:cancel_consumer/2 indeed returns a 3-tuple and not a pair.

michaelklishin commented 7 years ago

I corrected my hypothetic way of reproducing it. Looks like it was a server-initiated cancellation after all (via consumer cancel notification)

michaelklishin commented 7 years ago

Reproduced by running the echo example from RabbitMQ Web STOMP examples and deleting the queue it was using.

michaelklishin commented 7 years ago

It took a bit more than fixing the case clause but the hypothesis was correct. Submitted two pull requests for 3.6.10.

choyuri commented 7 years ago

wow thank you for the fast turn around!