我试图运行教程中的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
备注:
- RabbitMQ启动并工作-通过RabbitMQ管理web-UI轻松手动发送/获取消息。
1.命令rabbitmq-diagnostics.bat status接收到的状态或RabbitMQ正常,没有任何问题。 - exe文件添加到Windows防火墙,以避免任何阻塞
1.从Wireshark中我们可以看到RabbitMQ接受连接,并在一些操作后发送Reset:
来自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}]
**问题:**如何解决此问题?
1条答案
按热度按时间2skhul331#
给未来的读者。
这里的问题是您正在使用Erlang 26和RabbitMQ 3.11.x。使用Erlang 25。参见https://www.rabbitmq.com/which-erlang.html
Erlang 26还没有得到官方支持,我们正在努力;在3.12.x中的某个点将被支持。