Skip to content

Commit e7707ea

Browse files
authored
feat: set keepalive timeout to 59s (#101)
1 parent 82f07ff commit e7707ea

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

stream_chat/async_chat/client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def __init__(
4545
api_key=api_key, api_secret=api_secret, timeout=timeout, **options
4646
)
4747
self.session = aiohttp.ClientSession(
48-
connector=aiohttp.TCPConnector(keepalive_timeout=3.9)
48+
base_url=self.base_url,
49+
connector=aiohttp.TCPConnector(keepalive_timeout=59.0),
4950
)
5051

5152
async def _parse_response(self, response: aiohttp.ClientResponse) -> StreamResponse:
@@ -78,13 +79,11 @@ async def _make_request(
7879
headers["Authorization"] = self.auth_token
7980
headers["stream-auth-type"] = "jwt"
8081

81-
url = f"{self.base_url}/{relative_url}"
82-
8382
if method.__name__ in ["post", "put", "patch"]:
8483
serialized = json.dumps(data)
8584

8685
async with method(
87-
url,
86+
"/" + relative_url.lstrip("/"),
8887
data=serialized,
8988
headers=headers,
9089
params=default_params,
@@ -413,7 +412,7 @@ async def send_file(
413412
data.add_field("user", json.dumps(user))
414413
data.add_field("file", content, filename=name, content_type=content_type)
415414
async with self.session.post(
416-
f"{self.base_url}/{uri}",
415+
"/" + uri.lstrip("/"),
417416
params=self.get_default_params(),
418417
data=data,
419418
headers=headers,

0 commit comments

Comments
 (0)