Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange a2s.exceptions.BufferExhaustedError #45

Open
Nereg opened this issue Feb 25, 2023 · 3 comments
Open

Strange a2s.exceptions.BufferExhaustedError #45

Nereg opened this issue Feb 25, 2023 · 3 comments

Comments

@Nereg
Copy link
Contributor

Nereg commented Feb 25, 2023

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!

@Nereg
Copy link
Contributor Author

Nereg commented Feb 26, 2023

What I found so far:

  1. It isn't specific to 3.11.1. It still gives that error on 3.10.0 on linux
  2. It also affects sync variants of aplayers
  3. It affects both variants of rules. I didn't use that in my app so I didn't catch it on initial discovery.
  4. This doesn't affect PyPi version! I used code directly from master to get typing working.

So I will write back when I narrow down where the regression was introduced.

@Yepoleb
Copy link
Owner

Yepoleb commented Feb 27, 2023

I've noticed this too when merging the typing PR, thank you for investigating! I'd recommend you don't use master until it's stable again. I'll move the changes to a new branch (https://github.com/Yepoleb/python-a2s/tree/typing) to make it less likely to accidentally use the broken version.

@Nereg
Copy link
Contributor Author

Nereg commented Feb 28, 2023

Ok! Yeah I couldn't narrow down enough to see where this was introduced because of errors on each commit which I wouldn't want to fix in console lol. Good luck with typing though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants