From 70d1efccb164bae36c13e0486d1605689f7604ff Mon Sep 17 00:00:00 2001 From: VitoAlbano Date: Wed, 27 Nov 2024 12:39:47 +0000 Subject: [PATCH] Checking different way to build url --- .../src/lib/services/web-socket.service.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/process-services-cloud/src/lib/services/web-socket.service.ts b/lib/process-services-cloud/src/lib/services/web-socket.service.ts index 0b10f54925..25198fbe93 100644 --- a/lib/process-services-cloud/src/lib/services/web-socket.service.ts +++ b/lib/process-services-cloud/src/lib/services/web-socket.service.ts @@ -89,12 +89,13 @@ export class WebSocketService { ); } - private createWsUrl(serviceUrl: string): string { + private createWsUrl(apolloClientName: string, serviceUrl: string): string { const url = new URL(serviceUrl, this.host); - const protocol = url.protocol === 'https:' ? 'wss:' : 'ws:'; - url.protocol = protocol; - - return url.href; + const protocol2 = url.protocol === 'https:' ? 'wss:' : 'ws:'; + url.protocol = protocol2; + const protocol = this.host.split('://')[0] === 'https' ? 'wss' : 'ws'; + const subHost = this.host.split('://')[1]; + return `${protocol}://${subHost}/${apolloClientName}/notifications/ws/graphql`; } private createHttpUrl(serviceUrl: string): string { @@ -179,7 +180,7 @@ export class WebSocketService { private createTransportWsLink(options: serviceOptions) { this.wsLink = new WebSocketLink({ - uri: this.createWsUrl(options.wsUrl) + '/ws/graphql', + uri: this.createWsUrl(options.apolloClientName, options.wsUrl) + '/ws/graphql', options: { reconnect: true, lazy: true, @@ -194,7 +195,7 @@ export class WebSocketService { private createGraphQLWsLink(options: serviceOptions) { this.wsLink = new GraphQLWsLink( createClient({ - url: this.createWsUrl(options.wsUrl) + '/v2/ws/graphql', + url: this.createWsUrl(options.apolloClientName, options.wsUrl) + '/v2/ws/graphql', connectionParams: { Authorization: 'Bearer ' + this.authService.getToken() },