From 763ef241080bcb7f9c3be800989d5b0a4f2043f5 Mon Sep 17 00:00:00 2001 From: John Fleming Date: Fri, 2 Feb 2024 22:09:31 -0500 Subject: [PATCH 1/2] Address the telnet console bug. Add wait_for for drain() call. If we're stuck on drain then the buffer isn't getting emptied. 5 seconds after drain() blocks, exception will be thrown and client will be removed from connection table and will no longer be a problem. --- gns3server/utils/asyncio/telnet_server.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gns3server/utils/asyncio/telnet_server.py b/gns3server/utils/asyncio/telnet_server.py index b8829847..50f7defc 100644 --- a/gns3server/utils/asyncio/telnet_server.py +++ b/gns3server/utils/asyncio/telnet_server.py @@ -297,9 +297,17 @@ class AsyncioTelnetServer: reader_read = await self._get_reader(network_reader) # Replicate the output on all clients - for connection in self._connections.values(): - connection.writer.write(data) - await connection.writer.drain() + for connection_key in list(self._connections.keys()): + client_info = connection_key.get_extra_info("socket").getpeername() + connection = self._connections[connection_key] + + try: + connection.writer.write(data) + await asyncio.wait_for(connection.writer.drain(), timeout=10) + except: + log.debug(f"Timeout while sending data to client: {client_info}, closing and removing from connection table.") + connection.close() + del self._connections[connection_key] async def _read(self, cmd, buffer, location, reader): """ Reads next op from the buffer or reader""" From 3ced41633f5ee132a8ffba432c432c12dff2df1a Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 9 Feb 2024 17:07:35 +1100 Subject: [PATCH 2/2] Upgrade dependencies --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8191f4c4..3d293866 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ jsonschema>=4.17.3,<4.18 # v4.17.3 is the last version to support Python 3.7 aiohttp>=3.8.6,<3.9; python_version == '3.7' # v3.8.6 is the last version to support Python 3.7 -aiohttp>=3.9.0,<3.10; python_version > '3.7' +aiohttp>=3.9.3,<3.10; python_version > '3.7' aiohttp-cors>=0.7.0,<0.8 aiofiles>=23.2.1,<23.3 -Jinja2>=3.1.2,<3.2 +Jinja2>=3.1.3,<3.2 sentry-sdk==1.39.2,<1.40 psutil==5.9.8 -async-timeout>=4.0.2,<4.1 +async-timeout>=4.0.3,<4.1 distro>=1.9.0 py-cpuinfo>=9.0.0,<10.0 platformdirs>=2.4.0