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

bug: valheim player count is wrong #539

Open
PatricNox opened this issue Feb 11, 2024 · 17 comments
Open

bug: valheim player count is wrong #539

PatricNox opened this issue Feb 11, 2024 · 17 comments
Labels

Comments

@PatricNox
Copy link

PatricNox commented Feb 11, 2024

Describe the bug
2 people online, server is running on 2460, i tried both 2460 (game port) and 2461 (query port) but both gives 0 players online

Steps To Reproduce
Start valheim server, try gamedig

Screenshots or Data

image

image

image

Additional details

5.0.0-beta-2

@PatricNox PatricNox added the bug label Feb 11, 2024
@PatricNox
Copy link
Author

I actually think it is cus its a crossplay server, could it be it?
running on public 1

@podrivo
Copy link
Contributor

podrivo commented Feb 13, 2024

Hey! Did some testing in random servers from this list and didn't find any discrepancies.

Do you mind sharing the ip:port you were testing?

@CosminPerRam
Copy link
Member

@podrivo he mentioned the ports he tried and provided a code snippet that includes the IP: 167.86.77.2

I too have tried a bunch of random servers and they seem to respond as expected.

@podrivo
Copy link
Contributor

podrivo commented Feb 13, 2024

Oh, missed that... Thanks! (:

So, for the IP provided 167.86.77.2:2461, I was able to query successfully, with 0 players.
The response matches BattleMetrics: https://www.battlemetrics.com/servers/valheim/26250461

gamedig --type valheim --pretty 167.86.77.2:2461

{
  "name": "Leikjaseidr | discord.gg/EpcffzSSzh",
  "map": "Leikjaseidr | discord.gg/Epcffz",
  "password": true,
  "raw": {
    "protocol": 17,
    "folder": "valheim",
    "game": "",
    "appId": 892970,
    "numbots": 0,
    "listentype": "d",
    "environment": "l",
    "secure": 0,
    "steamid": "90180970892856320",
    "tags": [
      "g=0.217.38",
      "n=20",
      "m="
    ],
    "players": []
  },
  "version": "1.0.0.0",
  "maxplayers": 64,
  "numplayers": 0,
  "players": [],
  "bots": [],
  "queryPort": 2461,
  "connect": "167.86.77.2:2460",
  "ping": 304
}

@PatricNox
Copy link
Author

PatricNox commented Feb 14, 2024

I wonder if there is some weird setup on my end then, as I just again tried to see (5 players online - queried 0)

Any ideas what it could be? I am indeed running on 2460

@podrivo
Copy link
Contributor

podrivo commented Feb 14, 2024

I'm not sure what might be the issue.
Also, for this server in BattleMetrics, there were 0 players in the last 7 days.

image

@PatricNox
Copy link
Author

PatricNox commented Feb 16, 2024

Neither do I, in the last 7 days myself and a few people have played on the server so the metrics is not correct.

I suspected it to be a port issue - but since the query port actually retrieves correct server metadata, apart from player count, I am left baffled..

edit: here is an attached database query for all players that has been online the last 7 days

image

@CosminPerRam
Copy link
Member

Hmmmm, when creating Valheim servers, are there options for supporting multi platforms? This is just a thought but maybe the player count is correct on a single platform and reported incorrectly for multi platforms ones, if not, I don't really know whats going on here.

@PatricNox
Copy link
Author

Hmmmm, when creating Valheim servers, are there options for supporting multi platforms? This is just a thought but maybe the player count is correct on a single platform and reported incorrectly for multi platforms ones, if not, I don't really know whats going on here.

Yes its called "crossplay"
server is indeed running with it - hence my earlier suspection

@podrivo
Copy link
Contributor

podrivo commented Feb 25, 2024

image

@PatricNox Where did you get that screenshot? Which settings exist to toggle when creating the server?
In the platform column you can see (NULL), why do you think is that?

@PatricNox
Copy link
Author

PatricNox commented Feb 26, 2024

image

@PatricNox Where did you get that screenshot? Which settings exist to toggle when creating the server? In the platform column you can see (NULL), why do you think is that?

The screenshot is from a database I made to store character information, this is custom made and the data is filled in when players login to the server.

Here is an ingame screenshot of the very same server:

image

As you can see, there's players here - so I am clueless to why this is happening ,as the game seems to be able to retrieve the player count just fine but battlemetrics/gamedig not

image

This is the server startup:

exec /home/steam/valheim/server-files/valheim_server.x86_64 -name "UFBGaming.com • Vanilla" -port 2460 -nographics -batchmode -world "ufbnet_vanilla_srv" -password "XXXXXXXXX" -public 1  -crossplay >> srv.log

From Valheim docs, query port is port +1 (2460 + 1)

Thanks for sticking with me!

@PatricNox
Copy link
Author

Additionally: running with crossplay param, to let the server be connectable from both PC and Consoles, the server is using PlayFab.

Despite being clueless, my guess is around these crossplay areas..

@podrivo
Copy link
Contributor

podrivo commented Feb 26, 2024

One thing we could try is removing the -crossplay and try to query again, but with players on it, and see if it does make a difference.

On a second thought, do you know what the tags mean?

"tags": [
  "g=0.217.38",
  "n=20",
  "m=12\\",
  "30\\=1_0:2_0:3_0:4_0:5_0"
]

@PatricNox
Copy link
Author

One thing we could try is removing the -crossplay and try to query again, but with players on it, and see if it does make a difference.

On a second thought, do you know what the tags mean?

"tags": [
  "g=0.217.38",
  "n=20",
  "m=12\\",
  "30\\=1_0:2_0:3_0:4_0:5_0"
]

I will experiment with crossplay, just cant do that on the live server as console players will not have access anymore.

Regarding tags, where did you find them?
I've consulted the server manual and theres nothing about them there...

@podrivo
Copy link
Contributor

podrivo commented Feb 28, 2024

Got them from the query response:

gamedig --type valheim 167.86.77.2:2461 --pretty

{
  "name": "UFBGaming.com • Vanilla",
  "map": "UFBGaming.com • Vanilla",
  "password": true,
  "raw": {
    "protocol": 17,
    "folder": "valheim",
    "game": "",
    "appId": 892970,
    "numbots": 0,
    "listentype": "d",
    "environment": "l",
    "secure": 0,
    "version": "1.0.0.0",
    "steamid": "90188069517081600",
    "tags": [
      "g=0.217.38",
      "n=20",
      "m=12\\",
      "30\\=1_0:2_0:3_0:4_0:5_0"
    ],
    "players": []
  },
  "maxplayers": 64,
  "numplayers": 0,
  "players": [],
  "bots": [],
  "queryPort": 2461,
  "connect": "167.86.77.2:2460",
  "ping": 267
}

@PatricNox
Copy link
Author

Hello, I have been in contact with a developer of Valheim and I've found out the reason behind all this.

TLDR, it is indeed crossplay.

When crossplay is enabled, the local query port will show 0 players. The real number is exposed through another (less-accessible) channel to Valheim clients.

To work around this restriction, server operators typically query the operating system for UDP endpoints using a tool like netstat, ss, or lsof.

It's not as pretty:

https://github.com/lloesche/valheim-server-docker/blob/5c2b3262ef26832ffa9201fea441246f341c8548/common#L163

I was given this example along with a Quote:

And I should note that example will only tell if there are any players online. Getting an actual player count… I haven't seen someone figure that out from surface-level data yet.

So.. Yeah.. 🙃

@podrivo
Copy link
Contributor

podrivo commented Apr 21, 2024

Unfortunately, I'm not sure there's much we can do about this...
Let's just make sure we add this as a note in the documentation!

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

No branches or pull requests

3 participants