I am trying to connect my websocket spring server to a NATS as stomp broker
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config
.setApplicationDestinationPrefixes("/chatbot")
.enableStompBrokerRelay("/topic", "/queue")
.setRelayHost("localhost")
.setRelayPort(4223);
// config.enableSimpleBroker("/topic");
// config.setApplicationDestinationPrefixes("/app");
}
I follow this stackoverflow guide to create the NATS image, from the logs the image looks ok, also I am able to open a connection between my app and the NATS container
[1] 2024/08/10 12:45:01.559386 [INF] Starting nats-server
[1] 2024/08/10 12:45:01.559464 [INF] Version: 2.10.18
[1] 2024/08/10 12:45:01.559465 [INF] Git: [57d23ac]
[1] 2024/08/10 12:45:01.559466 [INF] Name: NA6STMILOGVMVYOABXRERUANYY32ANGA6TJSTVPU5NEPO3EKNXFPUARW
[1] 2024/08/10 12:45:01.559467 [INF] ID: NA6STMILOGVMVYOABXRERUANYY32ANGA6TJSTVPU5NEPO3EKNXFPUARW
[1] 2024/08/10 12:45:01.559470 [INF] Using configuration file: ws.conf
[1] 2024/08/10 12:45:01.559882 [INF] Listening for websocket clients on ws://0.0.0.0:4223
[1] 2024/08/10 12:45:01.559890 [WRN] Websocket not configured with TLS. DO NOT USE IN PRODUCTION!
[1] 2024/08/10 12:45:01.560092 [INF] Listening for client connections on 0.0.0.0:4222
[1] 2024/08/10 12:45:01.560525 [INF] Server is ready
However I am getting the following error repeatedly upon system start
2024-08-10T15:57:24.529+03:00 INFO 6307 --- [a4a] [ent-scheduler-3] o.s.m.s.s.StompBrokerRelayMessageHandler : TCP connection failure in session _system_: Transport failure: java.lang.IllegalArgumentException: No enum constant org.springframework.messaging.simp.stomp.StompCommand.HTTP/1.1 400 Bad Request
io.netty.handler.codec.DecoderException: java.lang.IllegalArgumentException: No enum constant org.springframework.messaging.simp.stomp.StompCommand.HTTP/1.1 400 Bad Request
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:500) ~[netty-codec-4.1.111.Final.jar:4.1.111.Final]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.FluxMap] :
reactor.core.publisher.Flux.cast(Flux.java:3587)
org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient$ReactorNettyHandler.apply(ReactorNettyTcpClient.java:317)
Error has been observed at the following site(s):
*_______Flux.cast ⇢ at org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient$ReactorNettyHandler.apply(ReactorNettyTcpClient.java:317)
|_ Flux.publishOn ⇢ at org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient$ReactorNettyHandler.apply(ReactorNettyTcpClient.java:318)
Original Stack Trace:
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:500) ~[netty-codec-4.1.111.Final.jar:4.1.111.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) ~[netty-codec-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:289) ~[netty-handler-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1407) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994) ~[netty-common-4.1.111.Final.jar:4.1.111.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.111.Final.jar:4.1.111.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.111.Final.jar:4.1.111.Final]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
Caused by: java.lang.IllegalArgumentException: No enum constant org.springframework.messaging.simp.stomp.StompCommand.HTTP/1.1 400 Bad Request
at java.base/java.lang.Enum.valueOf(Enum.java:293) ~[na:na]
at org.springframework.messaging.simp.stomp.StompCommand.valueOf(StompCommand.java:28) ~[spring-messaging-6.1.11.jar:6.1.11]
at org.springframework.messaging.simp.stomp.StompDecoder.decodeMessage(StompDecoder.java:143) ~[spring-messaging-6.1.11.jar:6.1.11]
at org.springframework.messaging.simp.stomp.StompDecoder.decode(StompDecoder.java:114) ~[spring-messaging-6.1.11.jar:6.1.11]
at org.springframework.messaging.simp.stomp.StompDecoder.decode(StompDecoder.java:87) ~[spring-messaging-6.1.11.jar:6.1.11]
at org.springframework.messaging.simp.stomp.StompReactorNettyCodec.decodeInternal(StompReactorNettyCodec.java:54) ~[spring-messaging-6.1.11.jar:6.1.11]
at org.springframework.messaging.tcp.reactor.AbstractNioBufferReactorNettyCodec.decode(AbstractNioBufferReactorNettyCodec.java:41) ~[spring-messaging-6.1.11.jar:6.1.11]
at org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient$StompMessageDecoder.decode(ReactorNettyTcpClient.java:339) ~[spring-messaging-6.1.11.jar:6.1.11]
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:530) ~[netty-codec-4.1.111.Final.jar:4.1.111.Final]
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:469) ~[netty-codec-4.1.111.Final.jar:4.1.111.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290) ~[netty-codec-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:289) ~[netty-handler-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1407) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) ~[netty-transport-4.1.111.Final.jar:4.1.111.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:994) ~[netty-common-4.1.111.Final.jar:4.1.111.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.111.Final.jar:4.1.111.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.111.Final.jar:4.1.111.Final]
at java.base/java.lang.Thread.run(Thread.java:1583) ~[na:na]
Any ideas on what is wrong? when moving to enableSimpleBroker
everything works ok of course