首页 > 解决方案 > SpringBoot AWS ActiveMQ消息代理错误:会话_system_中的TCP连接失败:传输失败:对等方重置连接

问题描述

我正在尝试使用 AWS ActiveMQ 作为 Spring Boot Websockets 的 STOMP 消息代理。当我使用在本地机器上运行的 ActiveMQ 本地实例运行我的应用程序时,一切正常,但是当我尝试连接到 AWS MQ(基于 Active MQ 的代理)时,我收到以下错误:

Oct 17 12:39:50 ip-172-31-36-140 web: 2021-10-17 12:39:50.727  INFO 4779 --- [ent-scheduler-1] o.s.m.s.s.StompBrokerRelayMessageHandler : TCP connection failure in session _system_: Transport failure: Connection reset by peer
Oct 17 12:39:50 ip-172-31-36-140 web: java.io.IOException: Connection reset by peer
Oct 17 12:39:50 ip-172-31-36-140 web: at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.8.0_302]
Oct 17 12:39:50 ip-172-31-36-140 web: at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.8.0_302]
Oct 17 12:39:50 ip-172-31-36-140 web: at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_302]
Oct 17 12:39:50 ip-172-31-36-140 web: at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.8.0_302]
Oct 17 12:39:50 ip-172-31-36-140 web: at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379) ~[na:1.8.0_302]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253) ~[netty-buffer-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1132) ~[netty-buffer-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350) ~[netty-transport-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151) ~[netty-transport-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719) ~[netty-transport-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986) ~[netty-common-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.67.Final.jar!/:4.1.67.Final]
Oct 17 12:39:50 ip-172-31-36-140 web: at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_302]

我检查了有关公开可用的代理的各种配置,并允许连接到安全组的入站规则中的各种端口。

我观察到的另一件事是,如果我尝试遵循示例,我可以毫无问题地连接到代理。

我在 Spring Boot 中是否缺少某些特定的东西,下面是我的配置类的代码片段:

@Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        final String STOMP_BROKER_HOST = environment.getProperty("STOMP_BROKER_HOST", "b-xxxxx.mq.ap-south-1.amazonaws.com");
        final int STOMP_BROLER_PORT = Integer.parseInt(environment.getProperty("STOMP_BROLER_PORT", "61614"));
        final String STOMP_BROLER_LOGIN = environment.getProperty("STOMP_BROLER_LOGIN", "****");
        final String STOMP_BROLER_PASSWORD = environment.getProperty("STOMP_BROLER_PASSWORD", "****");
        logger.info("Connecting to rabbitMQ at host {} port {} ", STOMP_BROKER_HOST, STOMP_BROLER_PORT);
        config.enableStompBrokerRelay("/topic/").setAutoStartup(true).setRelayHost(STOMP_BROKER_HOST)
                .setRelayPort(STOMP_BROLER_PORT).setClientLogin(STOMP_BROLER_LOGIN)
                .setClientPasscode(STOMP_BROLER_PASSWORD);
        config.setApplicationDestinationPrefixes("/app");
    }

在此处输入图像描述

有没有人遇到过类似的问题,可以请帮助我吗?

标签: javaamazon-web-servicesspring-bootwebsocketactivemq

解决方案


推荐阅读