Giter Club home page Giter Club logo

python-a2s's Introduction

Python A2S

Library to query Source and GoldSource servers. Implements Valve's Server Query Protocol. Rewrite of the python-valve module. Supports both synchronous and asyncronous applications.

Official demo application: Sourcequery

Requirements

Python >=3.7, no external dependencies

Install

pip3 install python-a2s or python3 setup.py install

API

Functions

  • a2s.info(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)
  • a2s.players(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)
  • a2s.rules(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING)

All functions also have an async version as of package 1.2.0 that adds an a prefix, e.g. ainfo, aplayers, arules.

Parameters

  • address: Tuple[str, int] - Address of the server.
  • timeout: float - Timeout in seconds. Default: 3.0
  • encoding: str or None - String encoding, None disables string decoding. Default: utf-8

Return Values

  • info: SourceInfo or GoldSrcInfo. They are documented in the source file.
  • players: List of Player items. Also documented in the corresponding source file.
  • rules: Dictionary of key - value pairs.

Exceptions

  • a2s.BrokenMessageError(Exception) - General decoding error
  • a2s.BufferExhaustedError(BrokenMessageError) - Response too short
  • socket.timeout - No response (synchronous calls)
  • asyncio.exceptions.TimeoutError - No response (async calls)
  • socket.gaierror - Address resolution error
  • ConnectionRefusedError - Target port closed
  • OSError - Various networking errors like routing failure

Examples

Example output shown may be shortened. Also the server shown in the example may be down by the time you see this.

>>> import a2s
>>> address = ("chi-1.us.uncletopia.com", 27015)
>>> a2s.info(address)
SourceInfo(protocol=17, server_name='Uncletopia | Chicago | 1', map_name='pl_badwater',
folder='tf', game='Team Fortress', app_id=440, player_count=24, max_players=24, bot_count=0,
server_type='d', platform='l', password_protected=False, vac_enabled=True, version='7370160',
edf=241, port=27015, steam_id=85568392924469984, stv_port=27016,
stv_name='Uncletopia | Chicago | 1 | STV', keywords='nocrits,nodmgspread,payload,uncletopia',
game_id=440, ping=0.2339219159912318)

>>> a2s.players(address)
[Player(index=0, name='AmNot', score=22, duration=8371.4072265625),
Player(index=0, name='TAAAAANK!', score=15, duration=6251.03173828125),
Player(index=0, name='Tiny Baby Man', score=17, duration=6229.0361328125)]

>>> a2s.rules(address)
{'coop': '0', 'cronjobs_version': '2.0', 'crontab_version': '2.0', 'deathmatch': '1',
'decalfrequency': '10', 'discord_accelerator_version': '1.0', 'discord_version': '1.0',
'extendedmapconfig_version': '1.1.1', 'metamod_version': '1.11.0-dev+1145V', 'mp_allowNPCs': '1'}

Notes

  • Some servers return inconsistent or garbage data. Filtering this out is left to the specific application, because there is no general approach to filtering that makes sense for all use cases. In most scenarios, it makes sense to at least remove players with empty names. Also the player_count value in the info query and the actual number of players returned in the player query do not always match up. Sometimes the player query returns an empty list of players.

  • For some games, the query port is different from the actual connection port. The Steam server browser will show the connection port and querying that will not return an answer. There does not seem to be a general solution to this problem so far, but usually probing port numbers up to 10 higher and lower than the connection port usually leads to a response. There's also the option of using http://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr={IP} to get a list of game servers on an IP (thanks to Nereg for this suggestion). If you're still not successful, use a network sniffer like Wireshark to monitor outgoing packets while refreshing the server popup in Steam.

  • Player counts above 255 do not work and there's no way to make them work. This is a limitation in the specification of the protocol.

  • This library does not implement rate limiting. It's up to the application to limit the number of requests per second to an acceptable amount to not trigger any firewall rules.

Tested Games

Half-Life 2, Half-Life, Team Fortress 2, Counter-Strike: Global Offensive, Counter-Strike 1.6, ARK: Survival Evolved, Rust

License

MIT

python-a2s's People

Contributors

mesosoi avatar nereg avatar yepoleb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-a2s's Issues

Rust server names

Hi! Im quite new to python aswell as network protocols so i thought i'd learn by making a small app to scrape the players on a rust server. It's going well, and reading your code aswell as some of the imports its using is getting me up to speed quicker than i thought. But i just now realized that the response im getting is the "streamer mode" names on the server (random names from a list). I've read the article on valve's dev-page and i can't find anything that would be able to change the information in the response-packet. So i thought since you've built the library maybe you have some better insight?

Sorry if this is not the place to put this, first time interacting on GitHub aswell. if so just remove or flag it as done! :)

socket.timeout: timed out

Tested on AlmaLinux 8.5 using Python 3.9 and Ubuntu 20.04 using Python 3.8. No extra packages installed. Tested on different networks and with different source servers (mostly CS:GO).

Steps to reproduce:

  1. Install a clean Linux
  2. pip3 install python-a2s or git clone and install (doesn't seems to make a difference)
  3. run the example code:
>>> import a2s
>>> address = ("stomping.kinofnemu.net", 27015)
>>> a2s.info(address)
  1. get the following error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/dist-packages/a2s/info.py", line 182, in info
    return request_sync(address, timeout, encoding, InfoProtocol)
  File "/usr/local/lib/python3.8/dist-packages/a2s/a2s_sync.py", line 22, in request_sync
    response = request_sync_impl(conn, encoding, a2s_proto)
  File "/usr/local/lib/python3.8/dist-packages/a2s/a2s_sync.py", line 28, in request_sync_impl
    resp_data = conn.request(a2s_proto.serialize_request(challenge))
  File "/usr/local/lib/python3.8/dist-packages/a2s/a2s_sync.py", line 92, in request
    return self.recv()
  File "/usr/local/lib/python3.8/dist-packages/a2s/a2s_sync.py", line 67, in recv
    packet = self._socket.recv(65535)
socket.timeout: timed out

Response 255 for Garry's Mod Servers

Hello, I don't see a format so here we go:

I get the parse error for Garry's Mod servers when I call the players() method with the code 255.

I have managed to work around this problem by disabling the check and reading the first uint32, then all the players were retrieved.

Below you can find the hack, I don't know how to fix this issue permanently.

    #if response_type != A2S_PLAYER_RESPONSE:
    #    raise BrokenMessageError(
    #        "Invalid response type: " + str(response_type))

    reader.read_uint32()

Right at L:48 of players.py

Server online at Steam but timed out using this library

Hi! I wanted to fetch info about server using your library (version 1.1.5 not async) and it timed out. But when I checkd server in steam it was online ! Here is link to screenshot. And here is my code:

import a2s
import arrow
import json
ip = "185.189.255.49"
port = 29036
address = (ip, port)
server = a2s.info(address)
players = a2s.players(address)
data = a2s.rules(address)
...

And I wonder if this is can be solved with increased timeout value if I will find out how to change it.

a2s.ainfo() leading to TypeError: raise_on_error() takes 0 positional arguments but 1 was given

Hello! I was working with your library and encountred such error:

Traceback (most recent call last):
  File "/app/src/updater.py", line 82, in update_server
    serverObj = await c.ARKServer(ip).AGetInfo() # get info about server
  File "/app/src/classes.py", line 37, in AGetInfo
    server = await a2s.ainfo((self.address,self.port)) # get server data
  File "/usr/local/lib/python3.7/site-packages/a2s/info.py", line 277, in ainfo
    resp_data = await conn.request(b"\x54Source Engine Query\0")
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 92, in request
    return await self.recv()
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 84, in recv
    self.protocol.raise_on_error()
TypeError: raise_on_error() takes 0 positional arguments but 1 was given

You can find code here (ARKServer.AGetInfo() and PlayersList.AgetPlayersList()). But sadly I couldn't reproduce that error on my computer so maybe it is affected by how many request I send (I update info about servers every 30 seconds or so)

[Question] Multiple Query

Is possible to query 1k or more servers at once to reduce processing time, if i have an list of 10k it will take minutes to query all the servers.
If yes can i have an example?

Proposal: add A2S_PING for query server

I can use this A2S protocol on L4D2 to query server-related information . Info, players and rules all work normally, but there is no ping.

Although I know that this function is so outdated that Counter-Stroke: Source and Team Fortress 2 are not supported, I still hope to see the implementation of this function.

I also know that this is an inappropriate request. If you don't agree, close this issue

Class attribute docstrings show wrong values.

So if you get a docstring for an attribute in a class on this library it shows docstring of next attribute:
image

python-a2s/a2s/info.py

Lines 16 to 33 in c09ff09

class SourceInfo(metaclass=DataclsMeta):
"""Protocol version used by the server"""
protocol: int
"""Display name of the server"""
server_name: str
"""The currently loaded map"""
map_name: str
"""Name of the game directory"""
folder: str
"""Name of the game"""
game: str
"""App ID of the game required to connect"""
app_id: int

As you can see it displays docstring value from next attribute (server_name) not correct one.
And it violates a part of PEP 257:

String literals occurring immediately after a simple assignment at the top level of a module, class, or __init__ method are called “attribute docstrings”.

So all of the docstrings in classes should be moved bellow the attributes to display correctly.

Which ports need to be unblocked, for a2s to work?

I'm trying to get the player count from a valheim container. I can get it to work when running the container locally, but not when I run it in the cloud. When it's in the cloud, I don't get a response from https://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=* (Just {"response":{"success":true,"servers":[]}}). (IP changes every time I reset the server.).

The ports I have unblocked are UDP 2456-2457, and I'm using 2457 for info. Because it works locally, the only thing I can think of is it's a firewall issue? The error I get is the classic timeout:

>>> a2s.info(("valheim-test.theamazingcameron.com", 2457), timeout=60)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/victor/Documents/GameManagement/.venv/lib64/python3.12/site-packages/a2s/info.py", line 182, in info
    return request_sync(address, timeout, encoding, InfoProtocol)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/victor/Documents/GameManagement/.venv/lib64/python3.12/site-packages/a2s/a2s_sync.py", line 22, in request_sync
    response = request_sync_impl(conn, encoding, a2s_proto)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/victor/Documents/GameManagement/.venv/lib64/python3.12/site-packages/a2s/a2s_sync.py", line 28, in request_sync_impl
    resp_data = conn.request(a2s_proto.serialize_request(challenge))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/victor/Documents/GameManagement/.venv/lib64/python3.12/site-packages/a2s/a2s_sync.py", line 92, in request
    return self.recv()
           ^^^^^^^^^^^
  File "/home/victor/Documents/GameManagement/.venv/lib64/python3.12/site-packages/a2s/a2s_sync.py", line 67, in recv
    packet = self._socket.recv(65535)
             ^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out

I can't find anything in the valve docs about any required port, and wireshark was way to noisy to get anything useful from. Do you have any idea what I might be missing?

OSError: [Errno 113] No route to host

Hello! So I discovered this new error in my logs. Library's version is 1.2.1 Here is it's stacktrace:

Traceback (most recent call last):
  File "/app/src/updater.py", line 157, in printer
    result = await self.update_server(server[0]) # update server
  File "/app/src/updater.py", line 119, in update_server
    serverObj = await c.ARKServer(ip).AGetInfo() # get info about server
  File "/app/src/classes.py", line 48, in AGetInfo
    server = await a2s.ainfo((self.address,self.port)) # get server data
  File "/usr/local/lib/python3.7/site-packages/a2s/info.py", line 277, in ainfo
    resp_data = await conn.request(b"\x54Source Engine Query\0")
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 92, in request
    return await self.recv()
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 84, in recv
    self.protocol.raise_on_error()
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 54, in raise_on_error
    raise error
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 957, in _read_ready
    data, addr = self._sock.recvfrom(self.max_size)
OSError: [Errno 113] No route to host

And I pinged and traceroute'ed host and it is up and running. Here is output of those:

root@7f8ba9b3d48e:/app# traceroute 31.214.160.82
traceroute to 31.214.160.82 (31.214.160.82), 30 hops max, 60 byte packets
 1  172.19.0.1 (172.19.0.1)  0.076 ms  0.014 ms  0.019 ms
 2  172.31.164.122 (172.31.164.122)  0.097 ms  0.053 ms  0.037 ms
 3  172.31.160.21 (172.31.160.21)  0.781 ms  1.133 ms  1.082 ms
 4  172.17.23.111 (172.17.23.111)  0.374 ms  0.339 ms  0.304 ms
 5  185.61.95.92 (185.61.95.92)  1.745 ms  1.778 ms  1.839 ms
 6  as199524.ix.dataix.ru (178.18.226.230)  46.742 ms  42.770 ms  43.334 ms
 7  10.255.4.172 (10.255.4.172)  51.857 ms  44.531 ms  48.388 ms
 8  92.223.125.75 (92.223.125.75)  44.268 ms  44.522 ms  42.297 ms
 9  95.156.239.10 (95.156.239.10)  39.957 ms  53.589 ms  55.457 ms
10  31.214.160.82 (31.214.160.82)  43.247 ms !X  39.988 ms !X  39.954 ms !X

And ping:

root@7f8ba9b3d48e:/app# ping 31.214.160.82
PING 31.214.160.82 (31.214.160.82) 56(84) bytes of data.
64 bytes from 31.214.160.82: icmp_seq=1 ttl=53 time=39.4 ms
64 bytes from 31.214.160.82: icmp_seq=2 ttl=53 time=39.5 ms
64 bytes from 31.214.160.82: icmp_seq=3 ttl=53 time=39.4 ms
^C
--- 31.214.160.82 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6ms

So there should not be such error. And also steam server viewer and ISteamApps/GetServersAtAddress shows no servers. But maybe they are offline and it should not give such error. But at least I would like to se this error mentioned in README
P.S. wow github why you referenced my commit

Request: Get MvM Mission and wave progress

Thanks for creating an awesome tool, would this be possible to add in? Getting the MvM Mission and wave would be really nice to be able to intergrate into other features of my community!

Async version of this library ?

Hi ! I am building bot for discord using async library so I wonderd if you can create or show me async analog of this library! Also if you nedd help to re-write some code I will help !

TypeError: raise_on_error() takes 0 positional arguments but 1 was given

Hello ! I got this strange error on my main server :

Traceback (most recent call last):
  File "/app/src/updater.py", line 157, in printer
    result = await self.update_server(server[0]) # update server
  File "/app/src/updater.py", line 119, in update_server
    serverObj = await c.ARKServer(ip).AGetInfo() # get info about server
  File "/app/src/classes.py", line 48, in AGetInfo
    server = await a2s.ainfo((self.address,self.port)) # get server data
  File "/usr/local/lib/python3.7/site-packages/a2s/info.py", line 277, in ainfo
    resp_data = await conn.request(b"\x54Source Engine Query\0")
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 92, in request
    return await self.recv()
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 84, in recv
    self.protocol.raise_on_error()
TypeError: raise_on_error() takes 0 positional arguments but 1 was given

Library version is 1.2.0. Python version is 3.7.4 Linux 32-bits Server ip is 51.81.75.174:27016
Also my test scripts don't fail like that. They report that the server is offline, But version there is 1.1.5 so I will try to update them and see if I can reproduse this.
P.S. Hey I got this error only on async version ! That smt at least to narrow search area.
Embarrassing AF

NameError: name 'BufferExhaustedError' is not defined

Hi, I have two errors going on here. The first is that I am receiving a BufferExhaustedError when calling a2s.info(address), though the same address responds with a valid response when using the old python-valve repo. The second error is that BufferExhaustedError appears to be undefined. Traceback:

Traceback (most recent call last):
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/python_a2s-1.1.2-py3.6.egg/a2s/info.py", line 199, in parse_source
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/python_a2s-1.1.2-py3.6.egg/a2s/byteio.py", line 41, in read_uint8
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/python_a2s-1.1.2-py3.6.egg/a2s/byteio.py", line 33, in unpack_one
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/python_a2s-1.1.2-py3.6.egg/a2s/byteio.py", line 30, in unpack
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/python_a2s-1.1.2-py3.6.egg/a2s/byteio.py", line 17, in read
a2s.exceptions.BufferExhaustedError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "query_server-a2s.py", line 33, in <module>
    info_dump = query_server(host, port)
  File "query_server-a2s.py", line 18, in query_server
    info = a2s.info(sqp_address)
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/python_a2s-1.1.2-py3.6.egg/a2s/info.py", line 256, in info
  File "/Users/andrew/.virtualenvs/python-valve-a2s/lib/python3.6/site-packages/python_a2s-1.1.2-py3.6.egg/a2s/info.py", line 200, in parse_source
NameError: name 'BufferExhaustedError' is not defined

unfortunately I cannot give you the address I am polling because it is proprietary.

TF2 Valve server queries timing out

Both a2s.info() and a2s.players() hang until timeout with seemingly all in-use Valve TF2 servers. Community servers still work fine, and old Valve server IPs I still have laying around technically work (I can still read server name and such), but any server I'd connected to in-game times out 100% of the time.

Examples:

  • 169.254.225.11, port 18384: yields this traceback after a 2 second timeout. Taking a look at the Steam servers API, there is definitely a running server there, as well as at a different port. This error also happens: at a longer timeout, when directly calling a2.info() from a REPL, when calling a2s.players(), and when outside of an IDE.
  • 169.254.25.245, port 13512: same traceback. Steam API says only one game server here.
  • 162.254.192.155, port 27053: this is a counterexample, in that it kind of works but also is an older IP address. Steam API says there are actually no servers there, but interestingly, when I just tested it I got these responses which have 6/6 players in MvM (it had been 0 players when I tested it in the past).
  • 192.223.26.238, port 27017: this is a LazyPurple server, which like all community servers I tested, works as expected.

This has been happening for several weeks, with every single server I've joined, but I only just got around to documenting and reporting it. Oddly, python-a2s is a crucial part of my program TF2 Rich Presence, but none of my users have reported any issues so I'm wondering if it's just me or something. I'm also not entirely convinced it's a bug in this library, but idk what else it could be. Python 3.10.2 32-bit, Windows 10 21H2

a2s.players name doesn't work for "7 Days to Die"

Like the Title says a2s.info and a2s.rules just work fine.
But a2s.player gives an list of players in which name is always an empty string and index and score is always 0
only duration seems to be working.

A2S_RULES not decoding correctly ?

Hello and thanks a lot for the API!
I try to get all mods on a server, for that I use the a2s_rules.
I'd like to know if it's decoded correctly ?

import a2s
address = ("205.178.177.120", 2303)
mods = a2s.rules(address)
print(mods)

->

{'\x01\n': '\x01\x01\x01\x02\x01\x01\x01\x02gn(T"d\x7fp�\x04�H��\x15DayZ-Expansion-Quests*\x01\x03�v\x04�\x1a��\x17Chernobyl Zone Building2�l5\x04�-��\x11UndergroundBunkerp��\x04\x04�p�e\x10BaseBuilding', '\x02\n': "Plus�Q�\x01\x01\x04��\x1eb\x08CodeLock6\x14�9\x04?�m�\x08MagicBox\x16�v�\x04\x05~�l\x0fBreachingcharge\x1b�\x08E\x04��Ł\nSPBuilding�\x07�\x04q���\x11BuildingsModPack7'�\x03\x1c\x04�\x07\x06�\x1dArma", '\x03\n': ' 2 Helicopters Remastered1\x1e�(\x04dS\x19�\x17Survivalists_FacePaints��l�\x04 ���\x0eDabs Framework�ڄ\x04]�k�\x13Rearmed Server Packnm\x15\x0b\x04�<Ý\x0eTactic', '\x04\n': 'al Flava�\x03��\x04[�U�\x0fCrocos QuadbikeNc�O\x04�+\x1f�\x06ZStuff\x0b"��\x04g橎\x0fTerrain Islands�ү�\x04��8m\rFlipTransport���\x17\x04�锌\x11IndustrialModPackɖ�', '\x05\n': '\x01\x01\x04.���\x14BuildingsMegaModPack.���\x04�ޙ�\x17DayZ-Expansion-Vehicles\x1d\x0f�:\x04ȩ��\x18DayZ-Expansion-Name-Tagsvž(\x04�l��\x19DayZ-Expansion-Animati', '\x06\n': 'ons��SE\x04�\x01\x03!~\x17DayZ-Expansion-Licensed|�\x13E\x04\x16�R�\x15DayZ-Expansion-Market�x{�\x04\\ޙ�\x13DayZ-Expansion-Core����\x04T��l\rVPPAdminTools?,\x10\x01\x01\x04�', '\x07\n': "Z��\x0eMagObfuscation$�\x16\x19\x04�(��\x12DayZ Editor Loaderk\x10�]\x04_A��\x13InventoryMoveSounds�\x1c*O\x04ztM�\x07Dogtags\x18��\x01\x01\x04\x01\x02\x08'k\x12WindstrideClothing'���\x04", '\x08\n': '(��v\rMuchStuffPack�\x1a\nt\x04\x04��\\\x13Community Framework\x16\x03BBP\x0bcftoolsRoot\nCodeLockv3\x0eCrocoDocPublic\x03CZB\x04dayz\tdesignful\tExpansion\tGormirn', '\t\n': 'TI\x04HDSN\tHelkhiana\x0cInclementDab\x0bItsATreeev2\x0eJacob_Mango_V3\tJosecitox\nliquidrock\tSPModding\x06Starlv\x03VPP\tWardog.v3\x07Wayward\nWindstrid', '\n\n': 'e', 'allowedBuild': '0', 'dedicated': '1', 'island': 'Enoch', 'language': '65545', 'platform': 'win', 'requiredBuild': '0', 'requiredVersion': '119', 'timeLeft': '15'}

Any idea on how to get the clean mods list ? :)

Thanks!

Get list of player names

Hi, I am trying to get a list of just the player names but I am struggling doing this. I know it is simple to do and I am just overlooking something simple. Previously I used the following code: `

            # Creates the string of player names used in the embed
            for player in server.players()["players"]:
                if player["name"]:
                    players.append(player["name"])
            player_count = len(players)
            players = ('\n'.join(map(str, players)))` 

I've tried just about every variation of this with the new a2s module and can't get just a list of players without the index, score, and duration as well. Can you help point me to what I am missing?

Valheim server doesn't return player info

I get back no information for the player's connected in Valheim. Before I go digging through the code, suggestions?

>>> import a2s
>>> address = ("localhost", 2457)
>>> a2s.info(address)
SourceInfo(protocol=17, server_name='<redacted>', map_name='<redacted>', folder='valheim', game='', app_id=0, player_count=1, max_players=64, bot_count=0, server_type='d', platform='w', password_protected=True, vac_enabled=False, version='1.0.0.0', edf=177, port=<redacted>, steam_id=<redacted>, stv_port=None, stv_name=None, keywords='0.203.11', game_id=<redacted>, ping=0.01600000000325963)
>>> a2s.players(address)
[Player(index=0, name='', score=0, duration=1207.71435546875)]
>>> a2s.rules(address)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\<servername>\AppData\Local\Programs\Python\Python310\lib\site-packages\a2s\rules.py", line 15, in rules
    return request_sync(address, timeout, encoding, RulesProtocol)
  File "C:\Users\<servername>\AppData\Local\Programs\Python\Python310\lib\site-packages\a2s\a2s_sync.py", line 22, in request_sync
    response = request_sync_impl(conn, encoding, a2s_proto)
  File "C:\Users\<servername>\AppData\Local\Programs\Python\Python310\lib\site-packages\a2s\a2s_sync.py", line 28, in request_sync_impl
    resp_data = conn.request(a2s_proto.serialize_request(challenge))
  File "C:\Users\<servername>\AppData\Local\Programs\Python\Python310\lib\site-packages\a2s\a2s_sync.py", line 92, in request
    return self.recv()
  File "C:\Users\<servername>\AppData\Local\Programs\Python\Python310\lib\site-packages\a2s\a2s_sync.py", line 67, in recv
    packet = self._socket.recv(65535)
TimeoutError: timed out

socket.timeout: timed out

Hi,

I try to run a simple example but I always get a timeout

import a2s

print("START")
address = ("85.190.148.87", 7779)
a2s.info(address)
packet = self._socket.recv(65535) 
socket.timeout: timed out

Rust server returning random player names instead of actual player names when using a2s.players

When using a2s.players() to query the players on a Rust server, it's returning random names or streamer mode names. I assume the server is doing this for some reason, is there a parameter that can be passed to have the server send actual player names instead of streamer mode names?

Thanks!

Player(index=0, name='bong', score=0, duration=47998.015625) Player(index=0, name='pete', score=0, duration=47993.86328125) Player(index=0, name='dannie', score=0, duration=47957.96484375) Player(index=0, name='laronda', score=0, duration=41854.796875) Player(index=0, name='cinderella', score=0, duration=39596.9296875) Player(index=0, name='laronda', score=0, duration=34884.58203125) Player(index=0, name='emilio', score=0, duration=33191.6640625) Player(index=0, name='nevada', score=0, duration=31335.51953125) Player(index=0, name='emily', score=0, duration=29443.658203125) Player(index=0, name='cyrstal', score=0, duration=26684.39453125) Player(index=0, name='tommye', score=0, duration=25533.060546875) Player(index=0, name='chanel', score=0, duration=24746.8359375) Player(index=0, name='santiago', score=0, duration=24659.7734375) Player(index=0, name='lou', score=0, duration=22130.740234375) Player(index=0, name='armandina', score=0, duration=21938.16015625) Player(index=0, name='micki', score=0, duration=20700.185546875) Player(index=0, name='pearle', score=0, duration=20458.982421875) Player(index=0, name='ulrike', score=0, duration=18077.22265625) Player(index=0, name='kayce', score=0, duration=17786.447265625) Player(index=0, name='deedra', score=0, duration=17664.4609375) Player(index=0, name='marquetta', score=0, duration=17653.259765625) Player(index=0, name='annamarie', score=0, duration=17591.43359375) Player(index=0, name='rosendo', score=0, duration=17322.8125) Player(index=0, name='marla', score=0, duration=16812.580078125) Player(index=0, name='tai', score=0, duration=16309.318359375) Player(index=0, name='deidre', score=0, duration=16165.7158203125) Player(index=0, name='donnetta', score=0, duration=15291.6767578125) Player(index=0, name='lani', score=0, duration=14520.0791015625) Player(index=0, name='lesha', score=0, duration=14421.8759765625) Player(index=0, name='jeana', score=0, duration=13168.6220703125) Player(index=0, name='donnette', score=0, duration=12777.1201171875)

a2s.rules doesn't work for goldsrc servers

import a2s

address = ("51.38.60.53", 27015)
print(a2s.info(address), "\n===================")
print(a2s.players(address), "\n===================")
print(a2s.rules(address), "\n===================")
❯ python3 test.py
GoldSrcInfo(address='51.38.60.53:27015', server_name='Emirates-KiNGS 亗 ||͇̿P͇̿U͇̿B͇̿L͇̿I͇̿C͇̿| ✪', map_name='de_dust2', folder='cstrike', game='Counter-Strike', player_count=32, max_players=32, protocol=47, server_type='d', platform='l', password_protected=False, is_mod=False, vac_enabled=True, bot_count=0, mod_website=None, mod_download=None, mod_version=None, mod_size=None, multiplayer_only=False, uses_hl_dll=True, ping=0.078310297) 
===================
[Player(index=0, name='0000000', score=3, duration=713.0708618164062), Player(index=1, name='CaNaPu5', score=20, duration=10951.25390625), Player(index=2, name='man', score=0, duration=3180.58349609375), Player(index=3, name='Naxo', score=2, duration=4307.5185546875), Player(index=4, name='ALAAAALA', score=31, duration=6036.9609375), Player(index=5, name='hoktri_spn', score=3, duration=828.8158569335938), Player(index=6, name='BENZEMA', score=37, duration=3634.5341796875), Player(index=7, name='Free World', score=22, duration=767.990966796875), Player(index=8, name='ﺭﻮﺴﻴﻓﻭﺮﺒﻟﺍ', score=1, duration=2330.75146484375), Player(index=9, name='[+]N0.$moK!ng[+]', score=0, duration=28.972854614257812), Player(index=10, name="lemon'haze", score=0, duration=983.9241943359375), Player(index=11, name='TheKiller', score=1, duration=1530.94287109375), Player(index=12, name='[S]KY', score=5, duration=1246.8905029296875), Player(index=13, name='FreeWillAboveAll ! _ celT1c^', score=62, duration=4017.47314453125), Player(index=14, name='pro,,man', score=31, duration=3365.847412109375), Player(index=15, name='misko pasaka', score=10, duration=1125.6868896484375), Player(index=16, name="-TatLA'", score=0, duration=26.366531372070312), Player(index=17, name='BABAK', score=32, duration=13625.2490234375), Player(index=18, name='Ali-G ((:', score=39, duration=2772.572509765625), Player(index=19, name='<3    NaSHmI   <3', score=43, duration=10373.259765625), Player(index=20, name='self.less', score=15, duration=1443.3994140625), Player(index=21, name='nomind', score=25, duration=4056.402587890625), Player(index=22, name='m@x1n3', score=13, duration=1183.256591796875), Player(index=23, name='QaFF', score=10, duration=1370.1153564453125), Player(index=24, name='OTTOMAN_cCc', score=18, duration=1803.26123046875), Player(index=25, name='CoMyNoMeRcY', score=20, duration=10086.8076171875), Player(index=26, name='GoaT', score=15, duration=1718.1759033203125), Player(index=27, name='Cigani ludaci!', score=14, duration=2449.064453125), Player(index=28, name='driloun', score=19, duration=9504.6044921875), Player(index=29, name='kappa', score=6, duration=817.0953369140625), Player(index=30, name='Dweezil', score=0, duration=18447.14453125), Player(index=31, name='usp', score=0, duration=1330.7908935546875)] 
===================
Traceback (most recent call last):
  File "/Users/sergejsorohov/Documents/trash/A2S_INFO-checker/src/test.py", line 7, in <module>
    print(a2s.rules(address), "\n===================")
  File "/usr/local/lib/python3.9/site-packages/a2s/rules.py", line 15, in rules
    return request_sync(address, timeout, encoding, RulesProtocol)
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 22, in request_sync
    response = request_sync_impl(conn, encoding, a2s_proto)
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 43, in request_sync_impl
    return request_sync_impl(
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 47, in request_sync_impl
    raise BrokenMessageError(
a2s.exceptions.BrokenMessageError: Invalid response type: 0x6d

Why rules not work?

Invalid response type: 0x6d or

Traceback (most recent call last):
  File "/Users/sergejsorohov/Documents/trash/A2S_INFO-checker/src/test.py", line 7, in <module>
    print(a2s.rules(address), "\n===================")
  File "/usr/local/lib/python3.9/site-packages/a2s/rules.py", line 15, in rules
    return request_sync(address, timeout, encoding, RulesProtocol)
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 22, in request_sync
    response = request_sync_impl(conn, encoding, a2s_proto)
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 43, in request_sync_impl
    return request_sync_impl(
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 28, in request_sync_impl
    resp_data = conn.request(a2s_proto.serialize_request(challenge))
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 92, in request
    return self.recv()
  File "/usr/local/lib/python3.9/site-packages/a2s/a2s_sync.py", line 76, in recv
    packet = self._socket.recv(4096)
socket.timeout: timed out

When i increase timeout - server not respond.

But all data from rules has been succefully parsed by every 3rd service
https://www.gametracker.com/server_info/51.38.60.53:27015/server_variables/

Different error with async version of library.

Hi! I was poking around async version of library and when server is offline there are different error not socket.timeout. Here is my traceback :

>>> newfeature = asyncio.get_event_loop().run_until_complete(test.AGetInfo())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "/app/src/classes.py", line 37, in AGetInfo
    server = await a2s.ainfo((self.address,self.port)) # get server data
  File "/usr/local/lib/python3.7/site-packages/a2s/info.py", line 277, in ainfo
    resp_data = await conn.request(b"\x54Source Engine Query\0")
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 92, in request
    return await self.recv()
  File "/usr/local/lib/python3.7/site-packages/a2s/a2sasync.py", line 86, in recv
    raise asyncio.TimeoutError()
concurrent.futures._base.TimeoutError

Plase add this to README Also I don't use addresses but there would be different error in DNS name resolution too

a2s.arules has data error while a2s.rules doesnt

Exception in callback _ProactorDatagramTransport._loop_reading(<_OverlappedF...sion\x001.3.'>)
handle: <Handle _ProactorDatagramTransport._loop_reading(<_OverlappedF...sion\x001.3.'>)>
Traceback (most recent call last):
  File "asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "asyncio\proactor_events.py", line 589, in _loop_reading
    self._protocol.datagram_received(data, addr)
  File "site-packages\a2s\a2s_async.py", line 70, in datagram_received
    self.fragment_buf.append(decode_fragment(payload))
                             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "site-packages\a2s\a2s_fragment.py", line 35, in decode_fragment
    frag.payload = bz2.decompress(reader.read())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "bz2.py", line 333, in decompress
    res = decomp.decompress(data)
          ^^^^^^^^^^^^^^^^^^^^^^^
OSError: Invalid data stream

This is being used in a asyncio.gather for many different servers if that matters.

Strange a2s.exceptions.BufferExhaustedError

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!

suggestion

if possibile add to a2s.players
the possibility to get the steamid of a person along with their username

since in many competitive games people tend to change their username to 123, or User
wich breaks gets in the way when you query a server.

Question

Hi how are things. I would like to ask, for example, if it is possible to install it in an iptables that I use to send the attacked IPS with a range of default ports (for example, all ports of 27015:27099) then the "clean" service comes out through another interface.

Thank you.

a2s not works for me

Hi, I have a problem with python-a2s. I make a request( .info() ) to my CS 1.6 server (195.88.209.185:27015) and I get an error: BufferExhaustedError.

Settings being returned are encrypted

I am trying to use this system to build an API to return data to create a server listing site. Currently when I request the server rules I get returned an encrypted response:
'game-settings-hash': 'b6d946d8046638f07908395427ececcbb0a12a06b08306d1537ac34ec2b6389c', 'settings0': 'AgAAAAAAAAAAAAAAAAAAAAAAAACgQAEMBAUAAAAAAAAAAAIAAAAAAwMAAAAABAQAAAAABQUAAAAABv4FAAAAAAAAAAAUAAAAABUyAAAAADNQAAAAAFGgAAAAAKH+', 'settings1': 'BAAAAAEeAwJQBQOWBwT6CQQAAAABAQIBAwEEAThkZjYJABEAChIAPAA8ADwAPAA8ADwAPAA8ADwAPAA8AEUAPAA8ADwAPAA8ADwAPAA8AD0APQA9AD0APEBOAEQA', 'settings2': 'RJBegFMAPAA8ADwAPAA8ADoAPM0wADwAPAA8ADoAPAA8ADoAQAA+ADwBAgACAgQAABEAFwARABcAEgAWABAAFgAEAgSbAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 'settings3': 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'}

What do I do to be able to read this data, Battlemetrics are doing this with no issue. What is the flaw in the process currently that is not allowing me to see this data in plain text?

Timeout even after receiving some data

Hello ! I spotted very strange things going on. So I tested server with IP 95.156.213.151:27017 (official ARK:SE server) and got such results:

$ py test.py
Received single packet: b'I\x11NA-PVP-Official-CrystalIsles808 - (v313.33)\x00CrystalIsles\x00ark_survival_evolved\x00ARK: Survival Evolved\x00\x00\x00\x13F\x00dw\x00\x011.0.0.0\x00\xb1c\x1e\x03<\x17\xdb\xd7<@\x01,OWNINGID:90138890338778115,OWNINGNAME:90138890338778115,NUMOPENPUBCONN:61,P2PADDR:90138890338778115,P2PPORT:7779,LEGACY_i:0\x00\xfeG\x05\x00\x00\x00\x00\x00'
Received single packet: b'A\xd7lT\t'
Received single packet: b'D\x13\x00\x00\x00\x00\x00\x00\xe3QLH\x00\x00\x00\x00\x00\x00\x12\x8eGH\x00\x00\x00\x00\x00\x00\x95\x8bEH\x00\x00\x00\x00\x00\x008\xf6<H\x00\x00\x00\x00\x00\x00\xb494H\x00\x00\x00\x00\x00\x00\x90\xe7,H\x00\x00\x00\x00\x00\x00\xce(\x90G\x00\x00\x00\x00\x00\x00\xde\xf9\x89G\x00\x00\x00\x00\x00\x00(\xfc\x83G\x00\x00\x00\x00\x00\x00\xbf\x9cqG\x00\x00\x00\x00\x00\x00\x7f\nKG\x00YA..\x00\x00\x00\x00\x00\xc6\xaf,F\x00123\x00\x00\x00\x00\x00\x08\x91\x12F\x00BlueEternal\x00\x00\x00\x00\x00uI\xa8E\x00123\x00\x00\x00\x00\x00\xb2\xeflE\x00awesome neon\x00\x00\x00\x00\x00id^E\x00kai\x00\x00\x00\x00\x00\xf3\x1c5E\x00123\x00\x00\x00\x00\x00\xf6\x1a,E\x00Davos[373]\x00\x00\x00\x00\x00\xd6\x03\x87D'
Traceback (most recent call last):
  File "test.py", line 19, in <module>
    data = asyncio.get_event_loop().run_until_complete(a2s.arules(address))
  File "c:\users\oleg\appdata\local\programs\python\python37-32\lib\asyncio\base_events.py", line 579, in run_until_complete
    return future.result()
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\rules.py", line 63, in arules
    reader = await rules_request_async(conn, encoding)
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\rules.py", line 68, in rules_request_async
    resp_data = await conn.request(b"\x56" + challenge.to_bytes(4, "little"))
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\a2sasync.py", line 92, in request
    return await self.recv()
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\a2sasync.py", line 86, in recv
    raise asyncio.TimeoutError()
concurrent.futures._base.TimeoutError

How it could be posible ? And by the way it only happens with async implementation. With sync one script finishes just fine. And you can find my script here Also here is output of the same script with sync calls:

$ py test.py
Received single packet: b'I\x11NA-PVP-Official-CrystalIsles808 - (v313.33)\x00CrystalIsles\x00ark_survival_evolved\x00ARK: Survival Evolved\x00\x00\x00\x11F\x00dw\x00\x011.0.0.0\x00\xb1c\x1e\x03<\x17\xdb\xd7<@\x01,OWNINGID:90138890338778115,OWNINGNAME:90138890338778115,NUMOPENPUBCONN:62,P2PADDR:90138890338778115,P2PPORT:7779,LEGACY_i:0\x00\xfeG\x05\x00\x00\x00\x00\x00'
Received single packet: b'A\xd7lT\t'
Received single packet: b'D\x11\x00\x00\x00\x00\x00\x00H\x9fLH\x00\x00\x00\x00\x00\x00w\xdbGH\x00\x00\x00\x00\x00\x00\xf9\xd8EH\x00\x00\x00\x00\x00\x00\x9dC=H\x00\x00\x00\x00\x00\x00\x19\x874H\x00\x00\x00\x00\x00\x00\xf44-H\x00\x00\x00\x00\x00\x00\x97\xc3\x90G\x00\x00\x00\x00\x00\x00\xa8\x94\x8aG\x00\x00\x00\x00\x00\x00Q\xd2rG\x00\x00\x00\x00\x00\x00\x11@LG\x00YA..\x00\x00\x00\x00\x00\x11\x861F\x00123\x00\x00\x00\x00\x00Sg\x17F\x00BlueEternal\x00\x00\x00\x00\x00\x0b\xf6\xb1E\x00awesome neon\x00\x00\x00\x00\x00\x94\xbdqE\x00123\x00\x00\x00\x00\x00"t?E\x00Davos[373]\x00\x00\x00\x00\x00,\xb6\xadD\x00\x00\x00\x00\x00\x00\xd0\x86KB'
Received single packet: b'A\xd7lT\t'
Received single packet: b'E\x16\x00ALLOWDOWNLOADCHARS_i\x001\x00ALLOWDOWNLOADITEMS_i\x001\x00ClusterId_s\x00NewPCPVP\x00CUSTOMSERVERNAME_s\x00na-pvp-official-crystalisles808\x00DayTime_s\x002394\x00GameMode_s\x00TestGameMode_C\x00HASACTIVEMODS_i\x000\x00LEGACY_i\x000\x00MATCHTIMEOUT_f\x00120.000000\x00ModId_l\x000\x00Networking_i\x000\x00NUMOPENPUBCONN\x0062\x00OFFICIALSERVER_i\x001\x00OWNINGID\x0090138890338778115\x00OWNINGNAME\x0090138890338778115\x00P2PADDR\x0090138890338778115\x00P2PPORT\x007779\x00SEARCHKEYWORDS_s\x00Custom\x00ServerPassword_b\x00false\x00SERVERUSESBATTLEYE_b\x00true\x00SESSIONFLAGS\x001707\x00SESSIONISPVE_i\x000\x00'
{'ALLOWDOWNLOADCHARS_i': '1', 'ALLOWDOWNLOADITEMS_i': '1', 'ClusterId_s': 'NewPCPVP', 'CUSTOMSERVERNAME_s': 'na-pvp-official-crystalisles808', 'DayTime_s': '2394', 'GameMode_s': 'TestGameMode_C', 'HASACTIVEMODS_i': '0', 'LEGACY_i': '0', 'MATCHTIMEOUT_f': '120.000000', 'ModId_l': '0', 'Networking_i': '0', 'NUMOPENPUBCONN': '62', 'OFFICIALSERVER_i': '1', 'OWNINGID': '90138890338778115', 'OWNINGNAME': '90138890338778115', 'P2PADDR': '90138890338778115', 'P2PPORT': '7779', 'SEARCHKEYWORDS_s': 'Custom', 'ServerPassword_b': 'false', 'SERVERUSESBATTLEYE_b': 'true', 'SESSIONFLAGS': '1707', 'SESSIONISPVE_i': '0'}
SourceInfo(protocol=17, server_name='NA-PVP-Official-CrystalIsles808 - (v313.33)', map_name='CrystalIsles', folder='ark_survival_evolved', game='ARK: Survival Evolved', app_id=0, player_count=17, max_players=70, bot_count=0, server_type='d', platform='w', password_protected=False, vac_enabled=True, version='1.0.0.0', edf=177, port=7779, steam_id=90138890338778115, stv_port=None, stv_name=None, keywords=',OWNINGID:90138890338778115,OWNINGNAME:90138890338778115,NUMOPENPUBCONN:62,P2PADDR:90138890338778115,P2PPORT:7779,LEGACY_i:0', game_id=346110, ping=0.1720000000204891)
.... here goes my own output...

So server's response for player request is different:
Async version:
b'D\x13\x00\x00\x00\x00\x00\x00\xe3QLH\x00\x00\x00\x00\x00\x00\x12\x8eGH\x00\x00\x00\x00\x00\x00\x95\x8bEH\x00\x00\x00\x00\x00\x008\xf6<H\x00\x00\x00\x00\x00\x00\xb494H\x00\x00\x00\x00\x00\x00\x90\xe7,H\x00\x00\x00\x00\x00\x00\xce(\x90G\x00\x00\x00\x00\x00\x00\xde\xf9\x89G\x00\x00\x00\x00\x00\x00(\xfc\x83G\x00\x00\x00\x00\x00\x00\xbf\x9cqG\x00\x00\x00\x00\x00\x00\x7f\nKG\x00YA..\x00\x00\x00\x00\x00\xc6\xaf,F\x00123\x00\x00\x00\x00\x00\x08\x91\x12F\x00BlueEternal\x00\x00\x00\x00\x00uI\xa8E\x00123\x00\x00\x00\x00\x00\xb2\xeflE\x00awesome neon\x00\x00\x00\x00\x00id^E\x00kai\x00\x00\x00\x00\x00\xf3\x1c5E\x00123\x00\x00\x00\x00\x00\xf6\x1a,E\x00Davos[373]\x00\x00\x00\x00\x00\xd6\x03\x87D'
Sync version:
b'D\x11\x00\x00\x00\x00\x00\x00H\x9fLH\x00\x00\x00\x00\x00\x00w\xdbGH\x00\x00\x00\x00\x00\x00\xf9\xd8EH\x00\x00\x00\x00\x00\x00\x9dC=H\x00\x00\x00\x00\x00\x00\x19\x874H\x00\x00\x00\x00\x00\x00\xf44-H\x00\x00\x00\x00\x00\x00\x97\xc3\x90G\x00\x00\x00\x00\x00\x00\xa8\x94\x8aG\x00\x00\x00\x00\x00\x00Q\xd2rG\x00\x00\x00\x00\x00\x00\x11@LG\x00YA..\x00\x00\x00\x00\x00\x11\x861F\x00123\x00\x00\x00\x00\x00Sg\x17F\x00BlueEternal\x00\x00\x00\x00\x00\x0b\xf6\xb1E\x00awesome neon\x00\x00\x00\x00\x00\x94\xbdqE\x00123\x00\x00\x00\x00\x00"t?E\x00Davos[373]\x00\x00\x00\x00\x00,\xb6\xadD\x00\x00\x00\x00\x00\x00\xd0\x86KB'
I would dive deeper and view what your library is sending in those two cases. Also I would analyse responses to find if it can be parsed anyway.

query is inaccurate

It displays an excessive amount of players, eg there were 5 people online (it was displaying 140 people online)

also for the game Ark Survival Evolved it does not seem that it queries players that are connected trough epicgames

player_count

Unresolved attribute reference 'player_count' for class 'Coroutine' error if i use async method

res = a2s.ainfo(address)

Fantom players

Hi one more time ! When I get list of players I encounter some players that isn't there. Here is screenshot. Theare are on list of players when getting it with your library but not there when getting it with steam. Also I attached to your logger so here is what logs look like. I don't know if it is happening with other servers or just with ARK servers. May be I can fix it without editing library.

DayZ info error

Hi!
Today I updated the library to the latest version and some of the servers that I polled correctly began to throw an exception a2s.BrokenMessageError. In this case, the rules and the players return correctly for both DayZ servers. In Steam, both servers are seen correctly by query port.
a2s.exceptions.BrokenMessageError: Invalid response type: 65
Help me understand what could be the reason for this behavior?

Please remove this. The problem was in my python and another library named a2s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.