GiyoMoon / steam-server-query

Module which implements the Master Server Query Protocol and Game Server Queries.
https://npmjs.com/package/steam-server-query
MIT License
25 stars 2 forks source link

Querying an Arma 3 server for players results in a buffer error #2

Closed eiqnepm closed 2 years ago

eiqnepm commented 2 years ago

Awesome package! I'm having issues querying Arma 3 servers. Do you know why this is?

const { queryGameServerPlayer } = require("steam-server-query");

queryGameServerPlayer("51.195.209.188:2303")
  .then((playerResponse) => {
    console.log(playerResponse);
  })
  .catch((err) => {
    console.error(err);
  });
RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds
    at new NodeError (node:internal/errors:371:5)
    at boundsError (node:internal/buffer:84:11)
    at Buffer.readInt32LE (node:internal/buffer:390:5)
    at GameServerQuery._readPlayer (node_modules\steam-server-query\lib\gameServer\gameServer.js:252:31)
    at GameServerQuery._parsePlayerBuffer (node_modules\steam-server-query\lib\gameServer\gameServer.js:219:37)      
    at GameServerQuery.player (node_modules\steam-server-query\lib\gameServer\gameServer.js:110:41)
    at async queryGameServerPlayer (node_modules\steam-server-query\lib\gameServer\gameServer.js:37:20) {
  code: 'ERR_BUFFER_OUT_OF_BOUNDS'
}
GiyoMoon commented 2 years ago

Hey! Thank you for using this package! Arma 3 server should follow the default A2S_PLAYER response format so its a bit odd that you get an error there. Did you try it with different Arma 3 servers? And if yes, could you provide me a few server addresses so that I can debug it with multiple examples? :) I will have a look today evening and will hopefully be able to fix it.

eiqnepm commented 2 years ago

Hey! Thank you for using this package! Arma 3 server should follow the default A2S_PLAYER response format so its a bit odd that you get an error there. Did you try it with different Arma 3 servers? And if yes, could you provide me a few server addresses so that I can debug it with multiple examples? :) I will have a look today evening and will hopefully be able to fix it.

Brilliant! I did test multiple servers without avail however after testing again just now it seems to be working as expected on most servers, which is quite strange as I've not changed anything. I'm still having the same issue however with two of the servers in the following.

const {
  // queryGameServerInfo,
  queryGameServerPlayer,
  // queryGameServerRules,
} = require("steam-server-query");

const hostArray = [
  "a2ws.arma.su:2503",
  "koth2.arma.su:2403",
  "koth1.arma.su:2303",
  "s1.grandtheftarma.com:2303",
  "events.grandtheftarma.com:2303",
  "altis.lyl.gg:2303",
  "tanoa.lyl.gg:2303",
  "cqc.lyl.gg:2303",
];

(async function () {
  for (const host of hostArray) {
    // console.log(`A2S_INFO for host ${host}`);
    // try {
    //   const infoResponse = await queryGameServerInfo(host);
    //   console.log(infoResponse);
    // } catch (err) {
    //   console.error(err);
    // }

    console.log(`A2S_PLAYER for host ${host}`);
    try {
      const playerResponse = await queryGameServerPlayer(host);
      console.log(playerResponse);
    } catch (err) {
      console.error(err);
    }

    // console.log(`A2S_RULES for host ${host}`);
    // try {
    //   const rulesResponse = await queryGameServerRules(host);
    //   console.log(rulesResponse);
    // } catch (err) {
    //   console.error(err);
    // }
  }
})();
GiyoMoon commented 2 years ago

Hey again! I found out why some servers result into out of bounds errors. Some servers seem to send multiple challenge requests, and only after the 3rd(?) one, the actual response is sent back. That is quite strange because this isn't stated in the steam documentation. I will add a challenge retry mechanism to hopefully prevent this from happening :)

GiyoMoon commented 2 years ago

Update: I made the changes and published it under version 1.1.3! If you run into any other issues, don't hesitate to open up this issue again :)

eiqnepm commented 2 years ago

Hey again! I found out why some servers result into out of bounds errors. Some servers seem to send multiple challenge requests, and only after the 3rd(?) one, the actual response is sent back. That is quite strange because this isn't stated in the steam documentation. I will add a challenge retry mechanism to hopefully prevent this from happening :)

Strange

Update: I made the changes and published it under version 1.1.3! If you run into any other issues, don't hesitate to open up this issue again :)

Super! Thanks!