Skip to content

Commit a72816c

Browse files
committed
fix: alpn http/1.1 for json client
1 parent 752ec8a commit a72816c

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

PasarGuardNodeBridge/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
- Extensible with custom metadata via the `extra` argument
1313
1414
Author: PasarGuard
15-
Version: 0.7.0
15+
Version: 0.7.1
1616
"""
1717

18-
__version__ = "0.7.0"
18+
__version__ = "0.7.1"
1919
__author__ = "PasarGuard"
2020

2121

PasarGuardNodeBridge/controller.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,18 @@ def __init__(
7171
try:
7272
self.api_key = UUID(api_key)
7373

74-
self.ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
75-
self.ctx.set_alpn_protocols(["h2"])
76-
self.ctx.load_verify_locations(cadata=server_ca)
77-
self.ctx.check_hostname = True
74+
self.h2_ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
75+
self.h2_ctx.load_verify_locations(cadata=server_ca)
76+
self.h2_ctx.check_hostname = True
77+
self.h2_ctx.set_alpn_protocols(["h2"])
78+
79+
self.http1_ctx = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
80+
self.http1_ctx.load_verify_locations(cadata=server_ca)
81+
self.http1_ctx.check_hostname = True
82+
self.http1_ctx.set_alpn_protocols(["http/1.1"])
83+
84+
# Backward-compatible alias for existing transport code that still expects `self.ctx`.
85+
self.ctx = self.h2_ctx
7886

7987
except ssl.SSLError as e:
8088
raise NodeAPIError(-1, f"SSL initialization failed: {str(e)}")
@@ -115,7 +123,7 @@ def __init__(
115123
self._shutdown_event = asyncio.Event()
116124

117125
self._json_client = LazyClientSession(
118-
ssl_context=self.ctx,
126+
ssl_context=self.http1_ctx,
119127
headers={"Content-Type": "application/json", "x-api-key": api_key},
120128
base_url=service_url,
121129
timeout=make_timeout(default_timeout),

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pasarguard-node-bridge"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
description = "python package to connect your project with PasarGuard node go"
55
url = "https://github.com/PasarGuard/node_bridge_py"
66
keywords = [

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)