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
605 stars 146 forks source link

bug: Get error with palworld server. No problem in CLI #511

Closed xenouch closed 8 months ago

xenouch commented 9 months ago

Hey,

I got this error when i call my function to get my Palworld server info. No probleme with other game "'Mincraft"

0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 Starting 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 Protocol: palworld 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 Options: { 0|admin | socketTimeout: '250', 0|admin | attemptTimeout: 10000, 0|admin | maxRetries: 1, 0|admin | stripColors: true, 0|admin | portCache: true, 0|admin | noBreadthOrder: false, 0|admin | ipFamily: 0, 0|admin | port: 8211, 0|admin | protocol: 'palworld', 0|admin | type: 'palworld', 0|admin | host: 'xx.xx.xx.xx', 0|admin | debug: true 0|admin | } 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 DNS Lookup: xx.xx.xx.xx 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 Raw IP Address: 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 Requesting external access token ... 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 Requesting deviceId access token ... 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 POST: https://api.epicgames.dev/auth/v1/accounts/deviceid 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 https://api.epicgames.dev/auth/v1/accounts/deviceid HTTP--> 0|admin | [24/01/2024 - 14:23:44] [LOG] Q#1 Query failed with error RequestError: Expected value which is predicate returns truthy for any value, received values of types string. 0|admin | at Request._destroy (file:///home/web/admin/node_modules/got/dist/source/core/index.js:481:21) 0|admin | at _destroy (node:internal/streams/destroy:121:10) 0|admin | at Request.destroy (node:internal/streams/destroy:83:5) 0|admin | at Request.flush (file:///home/web/admin/node_modules/got/dist/source/core/index.js:240:22) 0|admin | at lastHandler (file:///home/web/admin/node_modules/got/dist/source/create.js:37:26) 0|admin | at iterateHandlers (file:///home/web/admin/node_modules/got/dist/source/create.js:49:28) 0|admin | at got (file:///home/web/admin/node_modules/got/dist/source/create.js:69:16) 0|admin | at palworld.request (file:///home/web/admin/node_modules/gamedig/protocols/core.js:329:24) 0|admin | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 0|admin | at assertType (file:///home/web/admin/node_modules/@sindresorhus/is/dist/index.js:322:15) 0|admin | at Object.any (file:///home/web/admin/node_modules/@sindresorhus/is/dist/index.js:426:36) 0|admin | at set timeout [as timeout] (file:///home/web/admin/node_modules/got/dist/source/core/options.js:532:20) 0|admin | at Options.merge (file:///home/web/admin/node_modules/got/dist/source/core/options.js:415:27) 0|admin | at new Options (file:///home/web/admin/node_modules/got/dist/source/core/options.js:345:26) 0|admin | at new Request (file:///home/web/admin/node_modules/got/dist/source/core/index.js:224:28) 0|admin | at got (file:///home/web/admin/node_modules/got/dist/source/create.js:31:25) 0|admin | at palworld.request (file:///home/web/admin/node_modules/gamedig/protocols/core.js:329:24) 0|admin | at process.processTicksAndRejections (node:internal/process/task_queues:95:5) 0|admin | at async palworld._getDeviceIdToken (file:///home/web/admin/node_modules/gamedig/protocols/epic.js:65:22)

No probleme when i use cli

npx gamedig --type palworld xx.xx.xx.xx --debug Q#0 Starting Q#0 Protocol: palworld Q#0 Options: { socketTimeout: 2000, attemptTimeout: 10000, maxRetries: 1, stripColors: true, portCache: true, noBreadthOrder: false, ipFamily: 0, port: 8211, protocol: 'palworld', pretty: false, debug: true, givenPortOnly: false, requestRules: false, requestRulesRequired: false, requestPlayersRequired: false, checkOldIDs: false, type: 'palworld', host: 'xx.xx.xx.xx' } Q#0 DNS Lookup: xx.xx.xx.xx Q#0 Raw IP Address: xx.xx.xx.xx Q#0 Requesting external access token ... Q#0 Requesting deviceId access token ... Q#0 POST: https://api.epicgames.dev/auth/v1/accounts/deviceid Q#0 https://api.epicgames.dev/auth/v1/accounts/deviceid HTTP--> Q#0 https://api.epicgames.dev/auth/v1/accounts/deviceid <--HTTP 200 Q#0 POST: https://api.epicgames.dev/auth/v1/oauth/token Q#0 https://api.epicgames.dev/auth/v1/oauth/token HTTP--> Q#0 https://api.epicgames.dev/auth/v1/oauth/token <--HTTP 200 Q#0 POST: https://api.epicgames.dev/matchmaking/v1/0a18471f93d448e2a1f60e47e03d3413/filter Q#0 https://api.epicgames.dev/matchmaking/v1/0a18471f93d448e2a1f60e47e03d3413/filter HTTP--> Q#0 https://api.epicgames.dev/matchmaking/v1/0a18471f93d448e2a1f60e47e03d3413/filter <--HTTP 200 Q#0 Size of players array: 0 Q#0 Size of bots array: 0 Q#0 Query was successful { "name": "Cradingues Corp", "map": "MainWorld5", "raw": { "deployment": "0a18471f93d448e2a1f60e47e03d3413", "id": "25304a23ec274e71b10372fdc76892bd", "bucket": "Pal_1", "settings": { "maxPublicPlayers": 10, "allowInvites": false, "shouldAdvertise": true, "allowReadById": true, "allowJoinViaPresence": true, "allowJoinInProgress": true, "allowConferenceRoom": false, "checkSanctions": false, "allowMigration": false, "rejoinAfterKick": "", "platforms": null }, "totalPlayers": 0, "openPublicPlayers": 10, "publicPlayers": [], "started": true, "lastUpdated": null, "attributes": { "OWNINGUSERNAME_s": "DedicatedServer - palworld", "BUSESSTATS_b": false, "GAMESERVER_PORT_l": 8211, "DAYS_l": 8, "WORLDGUID_s": "DF01AF8DD8EF41139E4764649953F6F1", "NUMPRIVATECONNECTIONS_l": 0, "TYPE_s": "Community", "NAME_s": "Cradingues Corp", "CREATE_TIME_l": 1706103737, "SERVERTIME_l": 16, "DEDICATEDONLY_b": true, "ADDRESS_s": "xx.xx.xx.xx", "PRESENCESEARCH_b": true, "NUMPUBLICCONNECTIONS_l": 10, "BUILDUNIQUEID_l": 0, "ISPASSWORD_b": false, "VERSION_s": "v0.1.2.0", "NAMESPACE_s": "production", "BANTICHEATPROTECTED_b": false, "BISDEDICATED_b": true, "PLAYERS_l": 0, "MAPNAME_s": "MainWorld5" }, "owner": "Client_xyza78918C8ZyYGcxMcpvTQjPFdjtykx", "ownerPlatformId": null }, "maxplayers": 10, "numplayers": 0, "players": [], "bots": [], "queryPort": 8211, "connect": "xx.xx.xx.xx:8211", "ping": 0 }

Thanks in advance !

xenouch commented 9 months ago

The problem appears when i use the "socketTimeout" option. Default "2000" or custom "250" same thing crash

gamedig.GameDig.query({ type: ''+game+'', host: ''+host+'',
debug: true, socketTimeout: '2000', }).then((state) => { return state; })

Only work without "socketTimeout"

gamedig.GameDig.query({ type: ''+game+'', host: ''+host+'',
debug: true, }).then((state) => { return state; })

podrivo commented 9 months ago

Hello @xenouch! I'm not sure I follow your issue...

You should not see a difference when using a function or the CLI. What could be the case here, is that you are running different gamedig versions. Palworld was just recently added and some bugs were found, so make sure you're using the latest version on both scenarios.

About the socketTimeout, 2000 is the default time. If you're using 250, theres a big chance you'll get an error, as 250 might not be enough time to query and it will timeout.

Tried querying a random Palworld server and it didn't work when using 250, as expected.

// Works fine
gamedig --type palworld 195.18.27.172:8211 --socketTimeout 2000

// Error
gamedig --type palworld 195.18.27.172:8211 --socketTimeout 250
xenouch commented 9 months ago

Hello @podrivo

I'm using: 5.0.0-beta.0 when i get the error.

Yes, if i specify"socketTimeout" "default or custom value" for Palworld i get the error. If i dont specify "socketTimeout" i dont have any error

The "socketTimeout 250" is for my MC server. I understand it not work with all game and i adjust for specific game.

podrivo commented 9 months ago

I'm not sure I follow... Are you having problems with Palworld or Minecraft?

podrivo commented 8 months ago

@xenouch Are you still having problems querying your server?

xenouch commented 8 months ago

Sorry for the delay.

I dont have problem if i dont set socketTimeout "default value or custom"

This dont work

gamedig.GameDig.query({ type: ''palworld", host: ''+host+'',
debug: true, socketTimeout: '2000', }).then((state) => { return state; })

This work

gamedig.GameDig.query({ type: ''palworld", host: ''+host+'',
debug: true, }).then((state) => { return state; })

podrivo commented 8 months ago

2000 is the default for socketTimeout, so even though you don't specify a socketTimeout, it's still being passed as 2000. So it should not have a difference from both codes you posted.

@xenouch Would you mind posting the debug log from both options, please? With and without socketTimeout: '2000'.

Thank you!

xenouch commented 8 months ago

This is the result for palword:

Without socketTimeout https://pastebin.com/G7uxzf6x

With socketTimeout: '2000' https://pastebin.com/4h3XrzA8

With socketTimeout: 2000 "quote removed" https://pastebin.com/tJg6aRwe

I think the problem is the quote but i dont have problem with minecraft.

This is the result for minecraft:

Without socketTimeout https://pastebin.com/E0vwjYVb

With socketTimeout: '2000' https://pastebin.com/mcCES2Wn

With socketTimeout: 2000 "quote removed" https://pastebin.com/GUGXrFuQ

podrivo commented 8 months ago

Yeah, so the problem is definitely when using single quotes in your implementation. Minecraft is a special gem and may have different ways of working with socketTimeout, which may also be related to this other issue https://github.com/gamedig/node-gamedig/issues/370.

@xenouch That said, would you mind trying other games other than Minecraft to check this? No need to paste query responses, it would be just to confirm the use of single quotes breaking your implementation.

Best.

xenouch commented 8 months ago

I try with ts3 server when AT home !

xenouch commented 8 months ago

I try with teamspeak3 and counterstrike2

socketTimeout: '2000' - No problem

socketTimeout: 2000 - No problem

xenouch commented 8 months ago

I try with Ark: Survival Ascended who use [EOS Protocol] like Palworld

Same problem

socketTimeout: '2000' - Error

socketTimeout: 2000 - No problem

Maybe problem with EOS protocol !

CosminPerRam commented 8 months ago

You aren't supposed to pass the socketTimeout value as a string (with quotes), as documented in the readme, it must be a number (without quotes), regardless of protocol used.

CosminPerRam commented 8 months ago

TeamSpeak 3, CS2 and Minecraft all use raw sockets to get their data, ASA uses EOS which does a HTTP request.

Apparently, got (a library we use for http requests) throws an error if we pass the timeout as a string, here:

https://github.com/gamedig/node-gamedig/blob/fb6a5a1c7a3c9a12c5e81b5323883a45f3e1e344/protocols/core.js#L318-L323

Closing this as its not related to Palworld and this option is already documented to be passed as a number. Thanks for pointing this out! Feel free to reopen if problems still arise regarding this.