forget or remember 2023-06-14 18:56 采纳率: 33.3%
浏览 82

RabbitMQ创建Channel时报Connection reset


        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setPort(5672);
        connectionFactory.setUsername(username);
        connectionFactory.setPassword(password);
        connectionFactory.setHost("localhost");
        connectionFactory.setVirtualHost("/");
        var conn = connectionFactory.newConnection();
        var channel = conn.createChannel();
        conn.close();

这段代码会在channel建立的时候报Connection reset,用多种编程语言试过,请问可能有些什么原因,以下是RabbitMQ的日志

2023-06-29 18:53:02.258000+08:00 [info] <0.1204.0> accepting AMQP connection <0.1204.0> (127.0.0.1:2202 -> 127.0.0.1:5672)
2023-06-29 18:53:02.285000+08:00 [info] <0.1204.0> connection <0.1204.0> (127.0.0.1:2202 -> 127.0.0.1:5672): user 'guest' authenticated and granted access to vhost '/'
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> crasher:
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> initial call: rabbit_reader:init/3
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> pid: <0.1204.0>
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> registered_name: []
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> exception exit: {unexpected_message,{'EXIT',#Port<0.7257>,einval}}
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> in function rabbit_reader:handle_other/2 (rabbit_reader.erl, line 644)
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> in call from rabbit_reader:mainloop/4 (rabbit_reader.erl, line 535)
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> in call from rabbit_reader:run/1 (rabbit_reader.erl, line 457)
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> in call from rabbit_reader:start_connection/5 (rabbit_reader.erl, line 356)
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> ancestors: [<0.1202.0>,<0.599.0>,<0.598.0>,<0.597.0>,<0.595.0>,
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> <0.594.0>,rabbit_sup,<0.233.0>]
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> message_queue_len: 0
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> messages: []
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> links: [<0.1202.0>]
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> dictionary: [{{ch_pid,<0.1217.0>},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {1,#Ref<0.3908685128.610795521.253910>}},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {process_name,
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {rabbit_reader,<<"127.0.0.1:2202 -> 127.0.0.1:5672">>}},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {client_properties,
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> [{<<"product">>,longstr,<<"RabbitMQ">>},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"version">>,longstr,
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> <<"6.5.0+4c91cae8ae5eb0194e02a83f1b0cedfe29ad8312">>},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"platform">>,longstr,<<".NET">>},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"copyright">>,longstr,
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> <<"Copyright (c) 2007-2020 VMware, Inc.">>},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"information">>,longstr,
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> <<"Licensed under the MPL. See https://www.rabbitmq.com/%22%3E%3E},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"capabilities">>,table,
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> [{<<"publisher_confirms">>,bool,true},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"exchange_exchange_bindings">>,bool,true},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"basic.nack">>,bool,true},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"consumer_cancel_notify">>,bool,true},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"connection.blocked">>,bool,true},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"authentication_failure_close">>,bool,true}]},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<<"connection_name">>,void,undefined}]},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {{channel,1},
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> {<0.1217.0>,{method,rabbit_framing_amqp_0_9_1}}}]
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> trap_exit: true
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> status: running
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> heap_size: 1598
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> stack_size: 28
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> reductions: 9979
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0> neighbours:
2023-06-29 18:53:05.482000+08:00 [error] <0.1204.0>
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> supervisor: {<0.1202.0>,rabbit_connection_sup}
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> errorContext: child_terminated
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> reason: {unexpected_message,{'EXIT',#Port<0.7257>,einval}}
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> offender: [{pid,<0.1204.0>},
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> {id,reader},
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> {mfargs,{rabbit_reader,start_link,
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> [<0.1203.0>,
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> {acceptor,{127,0,0,1},5672}]}},
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> {restart_type,intrinsic},
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> {shutdown,300000},
2023-06-29 18:53:05.494000+08:00 [error] <0.1202.0> {child_type,worker}]
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> supervisor: {<0.1202.0>,rabbit_connection_sup}
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> errorContext: shutdown
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> reason: reached_max_restart_intensity
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> offender: [{pid,<0.1204.0>},
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> {id,reader},
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> {mfargs,{rabbit_reader,start_link,
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> [<0.1203.0>,
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> {acceptor,{127,0,0,1},5672}]}},
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> {restart_type,intrinsic},
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> {shutdown,300000},
2023-06-29 18:53:05.495000+08:00 [error] <0.1202.0> {child_type,worker}]

  • 写回答

4条回答

  • 枫飞雪飘 2023-06-14 19:36
    关注

    网络问题:检查网络连接是否正常,并确保能够连接到 RabbitMQ 服务器。您可以尝试通过 ping 命令或 telnet 命令来测试与服务器的连接。

    防火墙配置:确保防火墙允许与 RabbitMQ 服务器的通信。如果您的服务器上有防火墙,您需要确保 RabbitMQ 的端口(默认情况下为5672)是开放的。

    证书配置:如果您使用了 SSL/TLS 连接,可能会涉及到证书配置。确保您的证书配置正确,并且证书没有过期或被撤销。

    RabbitMQ 服务器配置:检查 RabbitMQ 服务器的配置文件,确保它正确配置并且没有错误。特别注意检查监听地址、端口和身份验证等配置项。

    并发连接限制:RabbitMQ 默认有一些并发连接限制。如果您的应用程序同时创建了大量的连接和通道,可能会达到服务器的限制。您可以尝试减少并发连接数量,或者调整 RabbitMQ 服务器的配置来提高并发连接的限制。

    评论

报告相同问题?

问题事件

  • 修改了问题 6月29日
  • 创建了问题 6月14日