Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ssl context #31

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hypha-rpc",
"version": "0.20.27",
"version": "0.20.28",
"description": "Hypha RPC client for connecting to Hypha server for data management and AI model serving.",
"main": "index.js",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion python/hypha_rpc/VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.20.27"
"version": "0.20.28"
}
2 changes: 2 additions & 0 deletions python/hypha_rpc/pyodide_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def __init__(
token=None,
reconnection_token=None,
timeout=5,
ssl=None,
):
assert server_url and client_id, "server_url and client_id are required"
self._server_url = server_url
Expand All @@ -147,6 +148,7 @@ def __init__(
self.connection_info = None
self._enable_reconnect = False
self.manager_id = None
assert ssl is None, "SSL is not supported in Pyodide"
if self._server_url.startswith("wss://local-hypha-server:"):
self._WebSocketClass = js.eval(
"("
Expand Down
7 changes: 5 additions & 2 deletions python/hypha_rpc/websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(
token=None,
reconnection_token=None,
timeout=60,
ssl=None,
):
"""Set up instance."""
self._websocket = None
Expand All @@ -69,6 +70,7 @@ def __init__(
self._legacy_auth = None
self.connection_info = None
self._enable_reconnect = False
self._ssl = ssl
self.manager_id = None

def on_message(self, handler):
Expand All @@ -92,7 +94,7 @@ async def _attempt_connection(self, server_url, attempt_fallback=True):
try:
self._legacy_auth = False
websocket = await asyncio.wait_for(
websockets.connect(server_url), self._timeout
websockets.connect(server_url, ssl=self._ssl), self._timeout
)
return websocket
except websockets.exceptions.InvalidStatusCode as e:
Expand Down Expand Up @@ -128,7 +130,7 @@ async def _attempt_connection_with_query_params(self, server_url):
full_url = f"{server_url}?{query_string}" if query_string else server_url

# Attempt to establish the WebSocket connection with the constructed URL
return await websockets.connect(full_url)
return await websockets.connect(full_url, ssl=self._ssl)

async def open(self):
"""Open the connection with fallback logic for backward compatibility."""
Expand Down Expand Up @@ -431,6 +433,7 @@ async def _connect_to_server(config):
token=config.get("token"),
reconnection_token=config.get("reconnection_token"),
timeout=config.get("method_timeout", 30),
ssl=config.get("ssl"),
)
connection_info = await connection.open()
assert connection_info, (
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "hypha_rpc"
version = "0.20.27"
version = "0.20.28"
description = "Hypha RPC client for connecting to Hypha server for data management and AI model serving"
readme = "README.md"
requires-python = ">=3.6"
Expand Down
Loading