From 5af12cea9738804fca7733be3b62cc725e90360b Mon Sep 17 00:00:00 2001 From: Marcos Candeia Date: Mon, 25 Nov 2024 17:07:02 -0300 Subject: [PATCH] Use ws/wss Signed-off-by: Marcos Candeia --- src/actors/proxyutil.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/actors/proxyutil.ts b/src/actors/proxyutil.ts index 820aac6..837c42d 100644 --- a/src/actors/proxyutil.ts +++ b/src/actors/proxyutil.ts @@ -336,17 +336,19 @@ export const createHttpInvoker = < invoke: async (name, method, methodArgs, metadata, connect?: true) => { const endpoint = urlFor(actorsServer.url, name, method); if (connect) { + const url = new URL(`${endpoint}?args=${ + encodeURIComponent( + btoa( + JSON.stringify({ + args: methodArgs ?? [], + metadata: metadata ?? {}, + }), + ), + ) + }&${ACTOR_ID_QS_NAME}=${actorId}`); + url.protocol = url.protocol === "http:" ? "ws:" : "wss:"; const ws = new WebSocket( - `${endpoint}?args=${ - encodeURIComponent( - btoa( - JSON.stringify({ - args: methodArgs ?? [], - metadata: metadata ?? {}, - }), - ), - ) - }&${ACTOR_ID_QS_NAME}=${actorId}`, + url, ); return makeWebSocket(ws) as Promise; }