RabbitMQ 关闭方法 CreateModel() 上的连接

问题描述 投票:0回答:0

我正在尝试运行教程中的 Producer 示例,但 RabbitMQ 异常关闭了连接:

抛出异常:RabbitMQ.Client.dll 中的“RabbitMQ.Client.Exceptions.OperationInterruptedException” RabbitMQ.Client.dll 中出现类型为“RabbitMQ.Client.Exceptions.OperationInterruptedException”的未处理异常 AMQP 操作被中断:AMQP close-reason,由 Library 发起,code=541,text='Unexpected Exception',classId=0,methodId=0,cause=System.IO.IOException:无法从传输连接读取数据: 现有连接被远程主机强行关闭。 ---> System.Net.Sockets.SocketException (10054): 现有连接被远程主机强制关闭。

代码是:

var factory = new ConnectionFactory { HostName = "localhost" };
var connection = factory.CreateConnection();
var channel = connection.CreateModel(); // <-- crash is here on this line

备注:

  1. RabbitMQ 启动并工作 - 很容易通过 RabbitMQ 管理 web-UI 手动发送/获取消息。
  2. 状态或 RabbitMQ 通过命令接收 rabbitmq-diagnostics.bat status 没问题,没问题。
  3. exe 文件添加到 Windows 防火墙以避免任何阻塞
  4. 从 Wireshark 中我们可以看到 RabbitMQ 接受连接并在一些操作之后发送重置:

Text

来自 RabbitMQ 日志:

2023-05-17 19:49:59.763000+03:00 [info] <0.930.0> accepting AMQP connection <0.930.0> ([::1]:49412 -> [::1]:5672)
2023-05-17 19:49:59.779000+03:00 [info] <0.930.0> connection <0.930.0> ([::1]:49412 -> [::1]:5672): user 'guest' authenticated and granted access to vhost '/'
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>   crasher:
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     initial call: rabbit_reader:init/3
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     pid: <0.930.0>
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     registered_name: []
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     exception exit: {unexpected_message,{'EXIT',#Port<0.229>,einval}}
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>       in function  rabbit_reader:handle_other/2 (rabbit_reader.erl, line 644)
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>       in call from rabbit_reader:mainloop/4 (rabbit_reader.erl, line 535)
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>       in call from rabbit_reader:run/1 (rabbit_reader.erl, line 457)
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>       in call from rabbit_reader:start_connection/5 (rabbit_reader.erl, line 356)
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     ancestors: [<0.928.0>,<0.603.0>,<0.602.0>,<0.601.0>,<0.599.0>,<0.598.0>,
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                   rabbit_sup,<0.233.0>]
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     message_queue_len: 0
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     messages: []
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     links: [<0.928.0>]
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     dictionary: [{{ch_pid,<0.939.0>},{1,#Ref<0.2052854348.121110529.34620>}},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                   {client_properties,
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                       [{<<"product">>,longstr,<<"RabbitMQ">>},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                        {<<"version">>,longstr,
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                         <<"6.5.0+4c91cae8ae5eb0194e02a83f1b0cedfe29ad8312">>},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                        {<<"platform">>,longstr,<<".NET">>},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                        {<<"copyright">>,longstr,
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                         <<"Copyright (c) 2007-2020 VMware, Inc.">>},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                        {<<"information">>,longstr,
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                         <<"Licensed under the MPL. See https://www.rabbitmq.com/">>},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                        {<<"capabilities">>,table,
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                         [{<<"publisher_confirms">>,bool,true},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                          {<<"exchange_exchange_bindings">>,bool,true},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                          {<<"basic.nack">>,bool,true},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                          {<<"consumer_cancel_notify">>,bool,true},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                          {<<"connection.blocked">>,bool,true},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                          {<<"authentication_failure_close">>,bool,true}]},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                        {<<"connection_name">>,void,undefined}]},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                   {process_name,
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                       {rabbit_reader,<<"[::1]:49412 -> [::1]:5672">>}},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                   {{channel,1},
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>                    {<0.939.0>,{method,rabbit_framing_amqp_0_9_1}}}]
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     trap_exit: true
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     status: running
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     heap_size: 1598
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     stack_size: 28
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>     reductions: 9624
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0>   neighbours:
2023-05-17 19:50:00.784000+03:00 [error] <0.930.0> 
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     supervisor: {<0.928.0>,rabbit_connection_sup}
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     errorContext: child_terminated
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     reason: {unexpected_message,{'EXIT',#Port<0.229>,einval}}
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     offender: [{pid,<0.930.0>},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {id,reader},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {mfargs,{rabbit_reader,start_link,
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                                       [<0.929.0>,
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                                        {acceptor,{0,0,0,0,0,0,0,0},5672}]}},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {restart_type,intrinsic},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {shutdown,300000},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {child_type,worker}]
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     supervisor: {<0.928.0>,rabbit_connection_sup}
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     errorContext: shutdown
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     reason: reached_max_restart_intensity
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>     offender: [{pid,<0.930.0>},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {id,reader},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {mfargs,{rabbit_reader,start_link,
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                                       [<0.929.0>,
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                                        {acceptor,{0,0,0,0,0,0,0,0},5672}]}},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {restart_type,intrinsic},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {shutdown,300000},
2023-05-17 19:50:00.784000+03:00 [error] <0.928.0>                {child_type,worker}]

问题:如何解决这个问题?

c# windows exception rabbitmq
© www.soinside.com 2019 - 2024. All rights reserved.