diff --git a/src/murfey/client/update.py b/src/murfey/client/update.py index d000b430e..49570bd1b 100644 --- a/src/murfey/client/update.py +++ b/src/murfey/client/update.py @@ -15,8 +15,9 @@ def check(api_base: ParseResult, install: bool = True, force: bool = False): If the version number is outside the allowed range then this can trigger an update on the client, and in that case will terminate the process. """ + proxy_path = api_base.path.rstrip("/") version_check_url = api_base._replace( - path="/version", query=f"client_version={murfey.__version__}" + path=f"{proxy_path}/version/", query=f"client_version={murfey.__version__}" ) server_reply = requests.get(version_check_url.geturl()) if server_reply.status_code != 200: @@ -59,6 +60,7 @@ def install_murfey(api_base: ParseResult, version: str) -> bool: Return 'true' on success and 'false' on error.""" assert api_base.hostname is not None + proxy_path = api_base.path.rstrip("/") result = subprocess.run( [ sys.executable, @@ -67,7 +69,7 @@ def install_murfey(api_base: ParseResult, version: str) -> bool: "--trusted-host", api_base.hostname, "-i", - api_base._replace(path="/pypi", query="").geturl(), + api_base._replace(path=f"{proxy_path}/pypi", query="").geturl(), f"murfey[client]=={version}", ] ) diff --git a/src/murfey/client/websocket.py b/src/murfey/client/websocket.py index 956800218..d693f14b9 100644 --- a/src/murfey/client/websocket.py +++ b/src/murfey/client/websocket.py @@ -25,16 +25,24 @@ def __init__( self.id = uuid.uuid4() if id is None else id log.info(f"Opening websocket connection for Client {self.id}") websocket.enableTrace(True) - url = urllib.parse.urlparse(server)._replace(scheme="ws", path="") + + # Parse server URL and get proxy path used, if any + url = urllib.parse.urlparse(server)._replace(scheme="ws") + proxy_path = url.path.rstrip("/") + self._address = url.geturl() self._alive = True self._ready = False self._send_queue: queue.Queue[Optional[str]] = queue.Queue() self._receive_queue: queue.Queue[Optional[str]] = queue.Queue() + + # Construct the websocket URL + # Prepend the proxy path to the new URL path + # It will evaluate to "" if nothing's there, and starts with "/" if present ws_url = ( - url._replace(path=f"/ws/test/{self.id}").geturl() + url._replace(path=f"{proxy_path}/ws/test/{self.id}").geturl() if register_client - else url._replace(path=f"/ws/connect/{self.id}").geturl() + else url._replace(path=f"{proxy_path}/ws/connect/{self.id}").geturl() ) self._ws = websocket.WebSocketApp( ws_url,