-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
STOMP Connection Closes Due to Missing Heartbeats Despite Frontend Showing Ping-Pongs #34009
Comments
Hi @abhishek0499, I've been playing with ActiveMQ-Artemis as relay broker but haven't been able to reproduce the error you described. It seems you might be using a custom configuration for Artemis because the default connection TTL is 60000ms and not 20000ms. Unfortunately you didn't share how you created your custom TcpClient. This is my configuration:
version: '3.8'
services:
broker:
image: apache/activemq-artemis:2.39.0
ports:
- "61613:61613"
- "61616:61616"
- "8161:8161"
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
private final String host = "127.0.0.1";
private final int port = 61613;
private final String username = "artemis";
private final String password = "artemis";
private final int sendInterval = 10000;
private final int receiveInterval = 10000;
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry
.addEndpoint("/ws")
.setAllowedOrigins("*")
.withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config
.setApplicationDestinationPrefixes("/app")
.enableStompBrokerRelay("/topic", "/queue")
.setUserDestinationBroadcast("/topic/random")
.setUserRegistryBroadcast("/topic/simp-user-registry")
.setTcpClient(createCustomTcpClient())
.setSystemLogin(username)
.setSystemPasscode(password)
.setClientLogin(username)
.setClientPasscode(password)
.setSystemHeartbeatSendInterval(sendInterval)
.setSystemHeartbeatReceiveInterval(receiveInterval);
}
private TcpOperations<byte[]> createCustomTcpClient() {
TcpClient tcpClient = TcpClient
.create()
.host(host)
.port(port);
return new ReactorNettyTcpClient<>(tcpClient, new StompReactorNettyCodec());
}
}
JS Client import SockJS from "sockjs-client";
import * as Stomp from "@stomp/stompjs";
const socket = new SockJS('http://localhost:8080/ws');
const stompClient = Stomp.Stomp.over(socket);
stompClient.connect({}, (frame) => {
stompClient.subscribe('/topic/random', (message) => {
console.log('Received message: ' + message.body);
});
}, (error) => {
console.error('Error: ', error);
}); So... check your TCP client - maybe you've set a very short connection timeout. Or maybe the traffic is interrupted at the network level in your environment. You can display extended logs from your client by setting wiretap in your client: TcpClient tcpClient = TcpClient.create()
.host(host)
.port(port)
.wiretap("reactor.netty", LogLevel.DEBUG, AdvancedByteBufFormat.TEXTUAL); and in your applicaton.yaml:
So you'll be able to check if heartbeat messages are sent correctly for both the Spring app and the JS client (ports for two will differ):
Cheers, |
Thank you for the response. I've tested the suggested approach with a single broker host-port configuration, and it works as expected. However, my use case involves multiple broker host-ports (e.g., I implemented a custom TcpClient using a
But when using multiple brokers, I'm still encountering the same TTL error as in my original issue. I've attached my current implementation for reference. Could you provide guidance on how to properly handle multiple broker connections while avoiding the TTL errors?
|
I’m experiencing a connection issue with WebSocket STOMP in Spring Boot using ActiveMQ Artemis. Despite proper heartbeat configurations, the broker closes the connection with the following error:
AMQ229014: Did not receive data from /192.0.2.1:46748 within the 20000ms connection TTL.
Setup
Logs confirm a CONNECTED frame with heart-beat=[10000, 10000].
Observations
Questions
Steps to Reproduce
Additional Context
Backend logs:
DEBUG StompBrokerRelayMessageHandler : Received CONNECTED heart-beat=[10000, 10000] session=itwv0lto DEBUG StompBrokerRelayMessageHandler : Forwarding SEND /topic/simp-user-registry session=_system_
The text was updated successfully, but these errors were encountered: