diff --git a/src/bus.ts b/src/bus.ts index c1d8bce..8b5a18f 100644 --- a/src/bus.ts +++ b/src/bus.ts @@ -145,6 +145,11 @@ export interface Bus { * Manually map channels, if turned off in RanchConfig. */ mapChannels(): void; + + /** + * Disable automatic reconnection attempts. + */ + disableReconnection(): void; } export interface CommandResponse { diff --git a/src/bus_engine.ts b/src/bus_engine.ts index 960eb51..5742aea 100644 --- a/src/bus_engine.ts +++ b/src/bus_engine.ts @@ -97,6 +97,9 @@ export class ranch implements Bus { // Log error to console console.error('STOMP Error received:', stompError.message, stompError); + // Disable reconnection for STOMP errors (typically server-side blocks) + this.disableReconnection(); + // Publish to error channel for centralized error handling const errorChannel = this.getChannel(ERROR_CHANNEL_NAME); errorChannel.publish({ @@ -145,6 +148,13 @@ export class ranch implements Bus { } } + disableReconnection(): void { + if (this._stompClient) { + this._stompClient.reconnectDelay = 0; + this._stompClient.maxReconnectDelay = 0; + } + } + private _mapDestination(destination: string, channel: string, persistMapping: boolean = true) { if (this._stompClient) { this._stompClient.subscribe(destination, message => {