gamedig / node-gamedig

Query game servers and not only! Node.JS/Deno/Bun or Bash (via the CLI).
https://www.npmjs.com/package/gamedig
MIT License
607 stars 146 forks source link

OpenTTD - Queries timing out on game version 12.0 and up #265

Open cyphercolt opened 2 years ago

cyphercolt commented 2 years ago

OpenTTD queries are timing out on game version 12.0 and up. Querying servers in the server list that are on a version below 12.0 have no issues.

Query log from my server:

root@8f329890b53f:/# gamedig --type openttd --debug 184.160.214.72:3979
Q#0 Starting
Q#0 Protocol: OpenTtd
Q#0 Options: {
  socketTimeout: 2000,
  attemptTimeout: 10000,
  maxAttempts: 1,
  port: 3979,
  protocol: 'openttd',
  requestRules: false,
  type: 'openttd',
  host: '184.160.214.72',
  debug: true
}
Q#0 DNS Lookup: 184.160.214.72
Q#0 Raw IP Address: 184.160.214.72
184.160.214.72:3979 UDP(46629)-->
Buffer length: 3 bytes
03 00 00 

184.160.214.72:3979 <--UDP(46629)
Buffer length: 3 bytes
03 00 01 

Q#0 Registered RTT: 20ms
Q#0 Query failed with error Error: Unknown protocol version: 0 Expected: 1-4
    at /usr/lib/node_modules/gamedig/protocols/openttd.js:107:23
    at socketCallback (/usr/lib/node_modules/gamedig/protocols/core.js:277:40)
    at Socket.<anonymous> (/usr/lib/node_modules/gamedig/lib/GlobalUdpSocket.js:30:21)
    at Socket.emit (node:events:520:28)
    at UDP.onMessage [as onmessage] (node:dgram:939:8)
Error: Failed all 1 attempts
    at QueryRunner.run (/usr/lib/node_modules/gamedig/lib/QueryRunner.js:95:21)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Gamedig.query (/usr/lib/node_modules/gamedig/lib/index.js:11:16)
Attempt #1 - Port=3979 Retry=0:
Error: Unknown protocol version: 0 Expected: 1-4
    at /usr/lib/node_modules/gamedig/protocols/openttd.js:107:23
    at socketCallback (/usr/lib/node_modules/gamedig/protocols/core.js:277:40)
    at Socket.<anonymous> (/usr/lib/node_modules/gamedig/lib/GlobalUdpSocket.js:30:21)
    at Socket.emit (node:events:520:28)
    at UDP.onMessage [as onmessage] (node:dgram:939:8)

Note - I commented out lines 106-108 in openttd.js just to skip the protocol version error and it still times out on the 12.x servers, queries fine on the 1.11.x servers and lower.

Out of curiosity, I also tried protocol-valve and got a timeout. (probably because openttd doesn't use the valve protocol at all, tried it anyway after reading through a bunch of the issues in github)

Feel free to use my IP to test gamedig queries for openttd.

Note I can query my unturned server on the same IP with port 27015 and get a result successfully (using --type protocol-valve and --type unturned).

mmorrisontx commented 2 years ago

Apparently they've ripped out all of the UDP query code 😞 https://github.com/OpenTTD/OpenTTD/commit/8a2da494138b9dda5ae94d83a95153f2c68afb58

cyphercolt commented 2 years ago

Apparently they've ripped out all of the UDP query code 😞 OpenTTD/OpenTTD@8a2da49

That'll explain why the server address no longer appears in the game server browser. I spent a good amount of time digging through reddit and openttd's discord looking for an ip for a 12.1 server to make sure it's not just my server.

cyphercolt commented 2 years ago

Thanks for checking though, I guess I'll close with this comment (This is my first ever github issue, spent several hours doing R&D making sure it's not a me-issue)

mmorrisontx commented 2 years ago

We can leave this open, in case someone feels like implementing their new TCP game coordinator api, if it's even possible. https://github.com/OpenTTD/OpenTTD/pull/9411