Skip to content

Commit

Permalink
[FIX] on websocket rewriting of the urls requires additional informat…
Browse files Browse the repository at this point in the history
…ion, added a hint to the url parse which designates whether gossiped URLs should be ws or wss based on current transport rather than on other heuristics.
  • Loading branch information
aricart committed Dec 3, 2023
1 parent 37f5bd6 commit f612ee2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nats-base-client/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ export interface Base {
}

export interface URLParseFn {
(u: string): string;
(u: string, encrypted?: boolean): string;
}

export enum ServiceVerb {
Expand Down
2 changes: 1 addition & 1 deletion nats-base-client/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ export class ProtocolHandler implements Dispatcher<ParserEvent> {
this.info = info;
const updates = this.options && this.options.ignoreClusterUpdates
? undefined
: this.servers.update(info);
: this.servers.update(info, this.transport.isEncrypted());
if (!this.infoReceived) {
this.features.update(parseSemVer(info.version));
this.infoReceived = true;
Expand Down
4 changes: 2 additions & 2 deletions nats-base-client/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,15 @@ export class Servers {
return this.servers;
}

update(info: ServerInfo): ServersChanged {
update(info: ServerInfo, encrypted?: boolean): ServersChanged {
const added: string[] = [];
let deleted: string[] = [];

const urlParseFn = getUrlParseFn();
const discovered = new Map<string, ServerImpl>();
if (info.connect_urls && info.connect_urls.length > 0) {
info.connect_urls.forEach((hp) => {
hp = urlParseFn ? urlParseFn(hp) : hp;
hp = urlParseFn ? urlParseFn(hp, encrypted) : hp;
const s = new ServerImpl(hp, true);
discovered.set(hp, s);
});
Expand Down

0 comments on commit f612ee2

Please sign in to comment.