From 5778b4d93f1e95000620292cfeca0f6370cb936d Mon Sep 17 00:00:00 2001 From: up-n-atom Date: Tue, 12 Sep 2023 15:53:27 -0400 Subject: [PATCH] Set client session for sagemcom client The default client session timeout is too short (7 seconds); Use the default from aiohttp (300 seconds) --- xmo-remote-client.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xmo-remote-client.py b/xmo-remote-client.py index f3f4fec..1205119 100755 --- a/xmo-remote-client.py +++ b/xmo-remote-client.py @@ -1,3 +1,5 @@ +from aiohttp import ClientSession, ClientTimeout +from aiohttp.connector import TCPConnector import asyncclick as click from enum import Enum from ipaddress import IPv4Address @@ -29,7 +31,13 @@ class EnumChoice(click.Choice): @click.pass_context async def cli(ctx: click.Context, host: str, username: str, password: str, authentication_method: EncryptionMethod) -> None: ctx.obj = client = await ctx.with_async_resource( - SagemcomClient(host, username, password, authentication_method, ssl=True, keep_keys=True) + SagemcomClient(host, username, password, authentication_method, + ClientSession( + headers={"User-Agent": "XMO_REMOTE_CLIENT/1.0.0"}, + timeout=ClientTimeout(), + connector=TCPConnector(ssl=True), + ), True, keep_keys=True + ) ) try: await client.login()