Skip to content

Commit

Permalink
fix: add wait on first connect to avoid pod restarts due to connectio…
Browse files Browse the repository at this point in the history
…n failures to nats
  • Loading branch information
mishraomp committed Dec 25, 2024
1 parent ec72a52 commit 5d019e2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions webeoc/src/publishers/actions-taken-publisher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class ActionsTakenPublisherService {
private async initializeNATS() {
const nc = await connect({
servers: [process.env.NATS_HOST],
waitOnFirstConnect: true,
});
this.jsClient = nc.jetstream();
}
Expand Down
1 change: 1 addition & 0 deletions webeoc/src/publishers/complaints-publisher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class ComplaintsPublisherService {
private async initializeNATS() {
const nc = await connect({
servers: [process.env.NATS_HOST],
waitOnFirstConnect: true,
});
this.jsClient = nc.jetstream();
}
Expand Down
2 changes: 1 addition & 1 deletion webeoc/src/subscribers/actions-taken-subscriber.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ActionsTakenSubscriberService implements OnModuleInit {

async onModuleInit() {
try {
this.natsConnection = await connect({ servers: process.env.NATS_HOST });
this.natsConnection = await connect({ servers: process.env.NATS_HOST, waitOnFirstConnect: true });
this.jsm = await this.natsConnection.jetstreamManager();
await this.setupStream();
await this.subscribeToTopics();
Expand Down
2 changes: 1 addition & 1 deletion webeoc/src/subscribers/complaints-subscriber.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class ComplaintsSubscriberService implements OnModuleInit {

async onModuleInit() {
try {
this.natsConnection = await connect({ servers: process.env.NATS_HOST });
this.natsConnection = await connect({ servers: process.env.NATS_HOST, waitOnFirstConnect: true });
this.jsm = await this.natsConnection.jetstreamManager();
await this.setupStream();
await this.subscribeToTopics();
Expand Down

0 comments on commit 5d019e2

Please sign in to comment.