Skip to content

Strange a2s.exceptions.BufferExhaustedError #45

@Nereg

Description

@Nereg

So recently while developing my app I encountered this error:

Traceback (most recent call last):
 ...
  File "/src/servers_updater/defaultA2S.py", line 26, in collect
    results = await asyncio.gather(*corutines)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/a2s/players.py", line 42, in aplayers
    return await request_async(address, timeout, encoding, PlayersProtocol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/a2s/a2s_async.py", line 32, in request_async
    response = await request_async_impl(conn, encoding, a2s_proto)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/a2s/a2s_async.py", line 60, in request_async_impl
    challenge = reader.read_uint32()
                ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/a2s/byteio.py", line 60, in read_uint32
    return self.unpack_one("L")
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/a2s/byteio.py", line 40, in unpack_one
    values = self.unpack(fmt)
             ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/a2s/byteio.py", line 37, in unpack
    return struct.unpack(new_fmt, self.read(fmt_size))
                                  ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/a2s/byteio.py", line 24, in read
    raise BufferExhaustedError()
a2s.exceptions.BufferExhaustedError

Here is my code:

    async def collect(self, serverList: list) -> list:
        corutines: list = []
        for server in serverList:
            ...
            corutines.append(a2s.ainfo(ip))
            corutines.append(a2s.aplayers(ip)) # <- this is where it fails as I can see from traceback 
        results = await asyncio.gather(*corutines)
        return results

The server is up and is successfully queried by steam server browser (without player data) and by my other app (with player data).
And I couldn't reproduce this on my dev machine (win 10, python 3.11.0). But I successfully reproduced in my docker container which is linux and python 3.11.1. I also captured traffic the container was making. And it doesn't respond after it received two challenge responses. Here is my capture of the traffic. (I removed the MAC addresses but payloads should be intact) Please let me know if you need more packets or the link had expired!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions