Skip to content

Commit 3297364

Browse files
committed
fix: update RabbitMQ frame_max parameter for 4.1+ compatibility
Updates the minimum frame_max value from 4096 to 8192 to meet the requirements of RabbitMQ 4.1+ servers. This resolves connection failures with newer RabbitMQ versions while maintaining backwards compatibility with older versions.
1 parent 427c994 commit 3297364

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ DATABASE_DELETE_MESSAGE=true
4747
RABBITMQ_ENABLED=false
4848
RABBITMQ_URI=amqp://localhost
4949
RABBITMQ_EXCHANGE_NAME=evolution
50+
RABBITMQ_FRAME_MAX=8192
5051
# Global events - By enabling this variable, events from all instances are sent in the same event queue.
5152
RABBITMQ_GLOBAL_ENABLED=false
5253
# Prefix key to queue name

src/api/integrations/event/rabbitmq/rabbitmq.controller.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,21 @@ export class RabbitmqController extends EventController implements EventControll
2121

2222
await new Promise<void>((resolve, reject) => {
2323
const uri = configService.get<Rabbitmq>('RABBITMQ').URI;
24+
const frameMax = configService.get<Rabbitmq>('RABBITMQ').FRAME_MAX;
2425
const rabbitmqExchangeName = configService.get<Rabbitmq>('RABBITMQ').EXCHANGE_NAME;
2526

26-
amqp.connect(uri, (error, connection) => {
27+
const url = new URL(uri);
28+
const connectionOptions = {
29+
protocol: url.protocol.slice(0, -1),
30+
hostname: url.hostname,
31+
port: url.port || 5672,
32+
username: url.username || 'guest',
33+
password: url.password || 'guest',
34+
vhost: url.pathname.slice(1) || '/',
35+
frameMax: frameMax
36+
};
37+
38+
amqp.connect(connectionOptions, (error, connection) => {
2739
if (error) {
2840
reject(error);
2941

src/config/env.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export type EventsRabbitmq = {
9494
export type Rabbitmq = {
9595
ENABLED: boolean;
9696
URI: string;
97+
FRAME_MAX: number;
9798
EXCHANGE_NAME: string;
9899
GLOBAL_ENABLED: boolean;
99100
EVENTS: EventsRabbitmq;
@@ -359,6 +360,7 @@ export class ConfigService {
359360
PREFIX_KEY: process.env?.RABBITMQ_PREFIX_KEY || 'evolution',
360361
EXCHANGE_NAME: process.env?.RABBITMQ_EXCHANGE_NAME || 'evolution_exchange',
361362
URI: process.env.RABBITMQ_URI || '',
363+
FRAME_MAX: Number.parseInt(process.env.RABBITMQ_FRAME_MAX) || 8192,
362364
EVENTS: {
363365
APPLICATION_STARTUP: process.env?.RABBITMQ_EVENTS_APPLICATION_STARTUP === 'true',
364366
INSTANCE_CREATE: process.env?.RABBITMQ_EVENTS_INSTANCE_CREATE === 'true',

0 commit comments

Comments
 (0)