我尝试使用 ActiveMQ (消息代理)配置 Websocket 。
启动 Springboot 应用程序时,我收到以下消息:
8.12.20 10:57:44.705 [tcp-client-loop-nio-3] INFO o.s.m.s.s.StompBrokerRelayMessageHandler - TCP connection failure in session _system_: Failed to connect: Connection timed out: no further information: /192.168.1.88:61613
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection timed out: no further information: /192.168.1.88:61613
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:636)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection timed out: no further information
这是 application.yml 中 ActiveMQ 的配置:
activemq:
broker-url: vm://embedded?broker.persistent=false,useShutdownHook=false
in-memory: true
non-blocking-redelivery: true
packages:
trust-all: false
trusted: com.memorynotfound
pool:
block-if-full: true
block-if-full-timeout: -1
enabled: false
idle-timeout: 30000
max-connections: 1
max-sessions-per-connection: 500
time-between-expiration-check: -1
use-anonymous-producers: true
# Spring JMS Settings
jms:
listener:
acknowledge-mode: auto
auto-startup: true
concurrency: 5
max-concurrency: 10
pub-sub-domain: false
template:
default-destination:
delivery-mode: NON_PERSISTENT
priority: 100
qos-enabled: true
receive-timeout: 1000
time-to-live: 36000
这是 Websocket 配置类:
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableStompBrokerRelay("/topic").setRelayHost("192.168.1.88").setRelayPort(61613);
config.setApplicationDestinationPrefixes("/app");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
...
}
}
我不知道relayHost和relayPort是否具有正确的值-我尝试了几对主机/端口,但没有成功(localhost,vm:// localhost,vm:// embedded等)
此错误(?)消息的性质是什么:ActiveMQ超时问题? relayHost和relayPort的当前值正确吗?...
有什么想法吗?
感谢您的进阶。