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

Valheim server doesn't return player info #28

Closed
kaltinril opened this issue Oct 17, 2021 · 7 comments
Closed

Valheim server doesn't return player info #28

kaltinril opened this issue Oct 17, 2021 · 7 comments

Comments

@kaltinril
Copy link

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
@Nereg
Copy link
Contributor

Nereg commented Oct 18, 2021

Yeah same here. Here is output of my test script on 189.1.168.21:26921:

$ py test.py
sent: b'TSource Engine Query\x00'
Received single packet: b'A\xdcm\x05N'
sent: b'TSource Engine Query\x00\xdcm\x05N'
Received single packet: b'I\x11deadheim\x00deadheim\x00valheim\x00\x00\x00\x00\x052\x00dl\x01\x001.0.0.0\x00\xb1(i\x05D\xb6{\xf7H@\x010.203.11-MagicOverhaul1.5.2\x00*\xa0\r\x00\x00\x00\x00\x00'
sent: b'U\x00\x00\x00\x00'
Received single packet: b'A\xdcm\x05N'
sent: b'U\xdcm\x05N'
Received single packet: b'D\x05\x00\x00\x00\x00\x00\x00\xd5\xdf\xc2E\x00\x00\x00\x00\x00\x00\xa1B\x9eE\x00\x00\x00\x00\x00\x00\xc6\xec(E\x00\x00\x00\x00\x00\x00\xaa\x1e E\x00\x00\x00\x00\x00\x00\xd9\x0cmD'
sent: b'V\x00\x00\x00\x00'
Received single packet: b'A\xdcm\x05N'
sent: b'V\xdcm\x05N'
Traceback (most recent call last):
  File "test.py", line 29, in <module>
    data = asyncio.get_event_loop().run_until_complete(a2s.arules(address))
  File "c:\users\oleg\appdata\local\programs\python\python38\lib\asyncio\base_events.py", line 608, in run_until_complete
    return future.result()
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\rules.py", line 18, in arules
    return await request_async(address, timeout, encoding, RulesProtocol)
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\a2s_async.py", line 22, in request_async
    response = await request_async_impl(conn, encoding, a2s_proto)
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\a2s_async.py", line 43, in request_async_impl
    return await request_async_impl(
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\a2s_async.py", line 28, in request_async_impl
    resp_data = await conn.request(a2s_proto.serialize_request(challenge))
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\a2s_async.py", line 137, in request
    return await self.recv()
  File "D:\Projects\Current\ARK Server monitor\lib\site-packages\a2s\a2s_async.py", line 130, in recv
    raise asyncio.TimeoutError()
asyncio.exceptions.TimeoutError

It seems like valheim isn't responding to rules request (see https://developer.valvesoftware.com/wiki/Server_queries#A2S_RULES). Sadly there is nothing library can do with such case.

@Yepoleb
Copy link
Owner

Yepoleb commented Oct 21, 2021

@Nereg Thanks for being so quick to help others!

If the server is not responding to the request there's nothing I can do about it. If the game has a player list somewhere in the server browser I might be able to help you to reverse engineer that, but that's out of scope for this particular library.

@jensbrak
Copy link

Well, now I tried to get this working but get similar problem - only that it's showing with a2s.info too:

>>> import a2s
>>> a = ("localhost", 2457)
>>> i = a2s.info(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/a2s/info.py", line 182, in info
    return request_sync(address, timeout, encoding, InfoProtocol)
  File "/usr/local/lib/python3.9/dist-packages/a2s/a2s_sync.py", line 22, in request_sync
    response = request_sync_impl(conn, encoding, a2s_proto)
  File "/usr/local/lib/python3.9/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.9/dist-packages/a2s/a2s_sync.py", line 92, in request
    return self.recv()
  File "/usr/local/lib/python3.9/dist-packages/a2s/a2s_sync.py", line 67, in recv
    packet = self._socket.recv(65535)
socket.timeout: timed out

@Nereg
Copy link
Contributor

Nereg commented Jan 14, 2022

Can you get player list/server info from LAN tab in Steam server browser? If not then library can't help because it implements protocol which is used in the browser.

@Yepoleb Yepoleb changed the title Valhiem server doesn't return player info Valheim server doesn't return player info Jan 15, 2022
@jensbrak
Copy link

It works just fine for me. Now.

Not sure why it started to work but maybe it is how the server is started or perhaps it needs a while before responding. I have to dig som more to get to know the workings of the Valheim server I run. But it does work now.

@Yepoleb Yepoleb closed this as completed Mar 6, 2022
@edwardsd97
Copy link

I am getting this same problem with a Valheim server I am running on linux.

@kira-xc
Copy link

kira-xc commented Apr 30, 2024

if u do ping localhost command or server ip => you will get 64 bytes from localhost icmp_seq=1 ttl=46 time=162 ms (DUP!)

the (DUP!)* Duplicate and Damaged Packets

so ... after this ping command u not receive other error
so for fix this error u need to add exception => every timeout error do : ping 5 times or 8 times on target address

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

6 participants