LinuxGSM icon indicating copy to clipboard operation
LinuxGSM copied to clipboard

[Bug]: After Valheim Update LGSM 'monitor' command no longer able to detect if Valheim is up

Open rychannel opened this issue 3 months ago • 9 comments

User story

As a Server Admin, I want LinuxGSM 'monitor' command to detect that Valheim is down and restart Valheim so that I can maintain a high SLA

Game

Valheim

Linux distro

Debian 12

Command

command: monitor

Further information

vhserver@valheim:~$ ./vhserver monitor
[  OK  ] Monitoring vhserver: Checking session ... OK
[ FAIL ] Monitoring vhserver: Querying port: gsquery: 127.0.0.1:2457 : 60/5 ... FAIL
[  OK  ] Monitoring vhserver: Sending Discord alert
[  OK  ] Stopping vhserver: Graceful: CTRL+c: 4 ... OK
[  OK  ] Starting vhserver: The Royal Refuge

Relevant log output


Steps to reproduce

  1. Run ./vhserver monitor

rychannel avatar Sep 09 '25 20:09 rychannel

I have the same issue. Removing vhserver monitor from my cron stopped the restarts, but monitor just fails.

tcpdump shows udp packets

$ sudo tcpdump -ni any port 2457
tcpdump: data link type LINUX_SLL2
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes

21:19:19.681037 lo    In  IP 127.0.0.1.52224 > 127.0.0.1.2457: UDP, length 25
21:19:21.684736 lo    In  IP 127.0.0.1.52224 > 127.0.0.1.2457: UDP, length 25
21:19:39.410283 lo    In  IP 127.0.0.1.51771 > 127.0.0.1.2457: UDP, length 25
21:19:59.941070 lo    In  IP 127.0.0.1.38532 > 127.0.0.1.2457: UDP, length 25

I initially did not have gamedig installed. I thought installing it might resolve my issue, but gamedig also fails:

vhserver@nuc:~$ gamedig --type valheim --host 127.0.0.1 --port 2457 --debug --attempts 5 --socketTimeout 2000
Q#0 Starting
Q#0 Protocol: valve
Q#0 Options: {
  socketTimeout: 2000,
  attemptTimeout: 10000,
  maxRetries: 1,
  stripColors: true,
  portCache: true,
  noBreadthOrder: false,
  ipFamily: 0,
  requestPlayers: true,
  port: 2458,
  protocol: 'valve',
  pretty: false,
  debug: true,
  givenPortOnly: false,
  requestRules: false,
  requestRulesRequired: false,
  requestPlayersRequired: false,
  checkOldIDs: false,
  rejectUnauthorized: false,
  type: 'valheim',
  host: '127.0.0.1',
  attempts: 5
}
Q#0 DNS Lookup: 127.0.0.1
Q#0 Raw IP Address: 127.0.0.1
Q#0 Requesting info ...
127.0.0.1:2458 UDP(38532)-->
Buffer length: 25 bytes
ff ff ff ff 54 53 6f 75 72 63 65 20 45 6e 67 69 6e 65 20 51 75
            T  S  o  u  r  c  e     E  n  g  i  n  e     Q  u
65 72 79 00
e  r  y

Q#0 UDP timeout detected
Q#0 Query failed with error Error: UDP - Timed out after 2000ms
    at Timeout.<anonymous> (file:///usr/lib/node_modules/gamedig/lib/Promises.js:7:18)
    at listOnTimeout (node:internal/timers:588:17)
    at process.processTimers (node:internal/timers:523:7)
Q#1 Starting
Q#1 Protocol: valve
Q#1 Options: {
  socketTimeout: 2000,
  attemptTimeout: 10000,
  maxRetries: 1,
  stripColors: true,
  portCache: true,
  noBreadthOrder: false,
  ipFamily: 0,
  requestPlayers: true,
  port: 2457,
  protocol: 'valve',
  pretty: false,
  debug: true,
  givenPortOnly: false,
  requestRules: false,
  requestRulesRequired: false,
  requestPlayersRequired: false,
  checkOldIDs: false,
  rejectUnauthorized: false,
  type: 'valheim',
  host: '127.0.0.1',
  attempts: 5
}
Q#1 DNS Lookup: 127.0.0.1
Q#1 Raw IP Address: 127.0.0.1
Q#1 Requesting info ...
127.0.0.1:2457 UDP(38532)-->
Buffer length: 25 bytes
ff ff ff ff 54 53 6f 75 72 63 65 20 45 6e 67 69 6e 65 20 51 75
            T  S  o  u  r  c  e     E  n  g  i  n  e     Q  u
65 72 79 00
e  r  y

Q#1 UDP timeout detected
Q#1 Query failed with error Error: UDP - Timed out after 2000ms
    at Timeout.<anonymous> (file:///usr/lib/node_modules/gamedig/lib/Promises.js:7:18)
    at listOnTimeout (node:internal/timers:588:17)
    at process.processTimers (node:internal/timers:523:7)
Error: Failed all 2 attempts
    at QueryRunner.run (file:///usr/lib/node_modules/gamedig/lib/QueryRunner.js:108:17)
    at async GameDig.query (file:///usr/lib/node_modules/gamedig/lib/gamedig.js:11:12)
Attempt #1 - Port=2458 Retry=0:
Error: UDP - Timed out after 2000ms
    at Timeout.<anonymous> (file:///usr/lib/node_modules/gamedig/lib/Promises.js:7:18)
    at listOnTimeout (node:internal/timers:588:17)
    at process.processTimers (node:internal/timers:523:7)
Attempt #2 - Port=2457 Retry=0:
Error: UDP - Timed out after 2000ms
    at Timeout.<anonymous> (file:///usr/lib/node_modules/gamedig/lib/Promises.js:7:18)
    at listOnTimeout (node:internal/timers:588:17)
    at process.processTimers (node:internal/timers:523:7)

The query port does not appear to be working? My server is otherwise online and working.

ss -tuplwn | grep valheim_server.

udp   UNCONN 0      0                               0.0.0.0:49077      0.0.0.0:*    users:(("valheim_server.",pid=524203,fd=51))
udp   UNCONN 19200  0                               0.0.0.0:2457       0.0.0.0:*    users:(("valheim_server.",pid=524203,fd=50))
udp   UNCONN 0      0                                     *:41373            *:*    users:(("valheim_server.",pid=524203,fd=46))
tcp   LISTEN 0      128                           127.0.0.1:41413      0.0.0.0:*    users:(("valheim_server.",pid=524203,fd=34))

bryanhiestand avatar Sep 09 '25 21:09 bryanhiestand

It looks like whatever changed might be in the crossplay/PlayFab path?

I don't see an option for it in lgsm, but removing -crossplay from startparameters fixes queries again (so monitor would work). In my case, I just did this since I don't think I need crossplay

cat <<'EOF' >> ~/lgsm/config-lgsm/vhserver/vhserver.cfg
startparameters="-name '${servername}' -password ${serverpassword} -port ${port} -world ${worldname} -public ${public} -savedir '${savedir}' -saveinterval ${saveinterval} -backups ${backups} -backupshort ${backupshort} -backuplong ${backuplong} -instanceid ${instanceid} ${logFile:+ -logFile '${logFile}'} ${worldmodifiers:+ ${worldmodifiers}}"
EOF

bryanhiestand avatar Sep 11 '25 01:09 bryanhiestand

While taking crossplay out of the config allowed monitor to work again, it made it so the server no longer showed up in the community server browser.

Khufuhk avatar Sep 13 '25 18:09 Khufuhk

It looks like whatever changed might be in the crossplay/PlayFab path?

I don't see an option for it in lgsm, but removing -crossplay from startparameters fixes queries again (so monitor would work). In my case, I just did this since I don't think I need crossplay

cat <<'EOF' >> ~/lgsm/config-lgsm/vhserver/vhserver.cfg startparameters="-name '${servername}' -password ${serverpassword} -port ${port} -world ${worldname} -public ${public} -savedir '${savedir}' -saveinterval ${saveinterval} -backups ${backups} -backupshort ${backupshort} -backuplong ${backuplong} -instanceid ${instanceid} ${logFile:+ -logFile '${logFile}'} ${worldmodifiers:+ ${worldmodifiers}}" EOF

LGSM used to have CROSSPLAY as optional (before it was officially supported). I've pulled it in to utilize in my /data/config-lgsm/vhserver.cfg

` # If crossplay is empty, it's off. Fill with any text to make true crossplay="1"

startparameters="-name "${servername}" -password ${serverpassword} -port ${port} -world "${worldname}" -public ${public} ${crossplay:+-crossplay} -savedir '${savedir}' -saveinterval ${saveinterval} -backups ${backups} -backupshort ${backupshort} -backuplong ${backuplong} -instanceid ${instanceid} ${logFile:+ -logFile '${logFile}'} ${worldmodifiers:+ ${worldmodifiers}}" `

irobot73 avatar Sep 16 '25 17:09 irobot73

While taking crossplay out of the config allowed monitor to work again, it made it so the server no longer showed up in the community server browser.

Made sure all your networking/port-forwarding is Kosher? IIRC, that's the only thing that dorked mine showing in the Comm. Server list....then I went CROSSPLAY (which negates any need for networking, but I kept it in case I ever had to disable C.P.)

irobot73 avatar Sep 16 '25 17:09 irobot73

This may have been fixed with a small Valheim update last night. This now works for me

vhserver@nuc:~$ ./vhserver monitor
[  OK  ] Monitoring vhserver: Checking session ... OK
[  OK  ] Monitoring vhserver: Querying port: gamedig: 127.0.0.1:2457 : 0/1 ... OK

core_exit.sh exiting with code: 0

bryanhiestand avatar Sep 17 '25 20:09 bryanhiestand

Problem persists for me after running all updates and restarting container. Crossplay on breaks Monitor and Crossplay off removes server from community list.

Khufuhk avatar Sep 17 '25 21:09 Khufuhk

I can confirm that Valheim made this change in the Call to Arms update. In a way it was a bug for it to start Steam lobby registration and expose the query port in Crossplay mode since you wouldn't be able to connect to the Steam-facilitated gameplay port in that mode anyway.

As others have suggested, LinuxGSM would either need to pick a querymode based on whether Crossplay was enabled or switch to session-based monitoring in the vhserver default config (allowing power users to override for gamedig or gsquery in the Steam/non-Crossplay mode).

JustinTArthur avatar Sep 17 '25 23:09 JustinTArthur

Problem persists for me after running all updates and restarting container. Crossplay on breaks Monitor and Crossplay off removes server from community list.

I am so sorry for the false noise on this issue! I forgot to re-enable crossplay before testing

bryanhiestand avatar Sep 17 '25 23:09 bryanhiestand