Fix managed mode WebSocket URL when server_url uses https://
The URL builder was prepending wss:// to the full https:// URL, producing an invalid wss://https://... URL. Now properly converts https→wss and http→ws before appending the /ws/transcribe path. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -320,9 +320,13 @@ class DeepgramTranscriptionEngine:
|
|||||||
def _build_ws_url_and_headers(self):
|
def _build_ws_url_and_headers(self):
|
||||||
"""Return ``(url, headers)`` depending on the current mode."""
|
"""Return ``(url, headers)`` depending on the current mode."""
|
||||||
if self.mode == "managed":
|
if self.mode == "managed":
|
||||||
# Ensure the server URL uses wss:// and append the path
|
# Convert HTTP(S) URLs to WS(S) for WebSocket connection
|
||||||
url = self.server_url.rstrip("/")
|
url = self.server_url.rstrip("/")
|
||||||
if not url.startswith("ws://") and not url.startswith("wss://"):
|
if url.startswith("https://"):
|
||||||
|
url = "wss://" + url[len("https://"):]
|
||||||
|
elif url.startswith("http://"):
|
||||||
|
url = "ws://" + url[len("http://"):]
|
||||||
|
elif not url.startswith("ws://") and not url.startswith("wss://"):
|
||||||
url = f"wss://{url}"
|
url = f"wss://{url}"
|
||||||
url = f"{url}/ws/transcribe"
|
url = f"{url}/ws/transcribe"
|
||||||
return url, {}
|
return url, {}
|
||||||
|
|||||||
Reference in New Issue
Block a user