Skip to content

Commit

Permalink
fix(nats): fix http to ws replacement
Browse files Browse the repository at this point in the history
fix(nats): fix http to ws replacement
  • Loading branch information
Passerino committed Dec 10, 2021
2 parents 0f58435 + af16531 commit 17de265
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/modules/messaging/messaging.service.ts
Expand Up @@ -30,15 +30,11 @@ export class MessagingService {
this._natsEnvironmentName = natsEnvironmentName;
this._jsonCodec = JSONCodec();
try {
let protocol = "ws";
if (natsServerUrl.indexOf("https://") === 0) {
protocol = "wss";
}
const timeout = 3000;
// this race condition duplicate timeout is there because unable to catch the error that occurs when NATS.ws timeouts
const connection = await Promise.race<NatsConnection | undefined>([
connect({
servers: `${protocol}://${natsServerUrl}`,
servers: natsServerUrl.replace("http", "ws"),
timeout,
pingInterval: 50 * 1000,
}),
Expand Down

0 comments on commit 17de265

Please sign in to comment.