Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T = any> {
Expand Down
10 changes: 10 additions & 0 deletions src/bus_engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 => {
Expand Down