Want to download client data

Hello. I’d like to download the number of users of my teamspeak server on the website, but after a few downloads everything stops working. Is there any limit on logging in to query over time or something?

this is my code (express in node.js using api):

const tsClient = new TeamSpeak(data.ts.ip, data.ts.port);

tsClient.send('login', {
    client_login_name: data.ts.user,
    client_login_password: data.ts.password
}, function(err, response, request) {
    tsClient.send('use', {
        sid: 1
    }, function(err, response, request) {

        tsClient.send('clientlist', function(err, response, request) {
            const data = {
                online: response.data.length
            }
            res.writeHead(200, {'Content-Type': 'application/json'});
            res.write(JSON.stringify(data));
            res.end();
        });
    });
});

You may have been rate limited.
If you’re sure your ServerQuery access is save you can add query_skipbruteforcecheck=1 as start parameter or in your server config file. This will stop query commands from being rate limited.


Just as note…

Instead of using the TS API for node.js you could you node-fetch to send a request to the WebQuery interface of your server. And instead of receiving the whole client list the query command serverinfo will contain the total amount of connected clients, too.

Example:

const Fetch = require("node-fetch");

Fetch("http://12.34.56.78:10080/1/serverinfo", { method: "GET", headers: { "Content-Type": "application/json", "x-api-key": "9MpRMXK1KI0YRL4WAN3e82GOg5yZiU76HqjE" } }).then((response) => response.json()).then((json) => console.log(json.body[0].virtualserver_clientsonline));

An async function makes more sense waiting for the response:

const Fetch = require("node-fetch");

async function fetchClientCount()
{
	let client_count = 0;
	
	await Fetch("http://12.34.56.78:10080/1/serverinfo", { method: "GET", headers: { "Content-Type": "application/json", "x-api-key": "9MpRMXK1KI0YRL4WAN3e82GOg5yZiU76HqjE" } }).then((response) => response.json()).then((json) => { if(json.body[0].virtualserver_clientsonline) client_count = json.body[0].virtualserver_clientsonline; }).catch(console.error);
	
	console.log(client_count);
}

fetchClientCount();

if(json.body[0].virtualserver_clientsonline) will check if the property exists.
It’s possible the WebQuery interface responds with an error message and the array body doesn’t exist.

This method requires to create a TeamSpeak API key and to activate the WebQuery interface.
It’s also needed to open/forward the required port for the interface (10080 TCP by default).

1 Like

Thank you!

Anyway…
First option doesn’t work (I try config and parameter - nothing works).
Soon i try your second advice.

1 Like

That strongly depends how you start your TeamSpeak server.

The ts3server_startscript.sh requires to add the parameters in the file.
The ts3server_minimal_runscript.sh will listen to all passed arguments.

I would recommend to use the ts3server.ini file for all config parameters.


Assuming you’re running TeamSpeak on Linux it may be a good idea to create a service if TeamSpeak crashes. As long as you let the service add the PID file to your TeamSpeak root path you can stop the server using the common startscript.

Example:

ExecStart=/home/teamspeak/teamspeak3-server_linux_amd64/ts3server_minimal_runscript.sh inifile=ts3server.ini
ExecStop=/home/teamspeak/teamspeak3-server_linux_amd64/ts3server_startscript.sh stop
PIDFile=/home/teamspeak/teamspeak3-server_linux_amd64/ts3server.pid
1 Like

I create ts3server.ini and put query_skipbruteforcecheck=1 into this and nothing works. Launching by ts3server_startscript.sh

As I mentioned above the startscript requires to edit the file and add the parameters into the file.
There should be a var somewhere with a comment like “start parameters here”.

I’m unable to open and show you the content on mobile.

Meanwhile to test just use the minimal startscript to start the server.

./ts3server_minimal_runscript.sh inifile=ts3server.ini

Make sure the ts3server.ini is placed your TeamSpeak root path.

1 Like

I try it yet ./ts3server_minimal_runscript.sh query_skipbruteforcecheck=1 but doesn’t work.
And this file is a complicated thing, I don’t know what is what :confused: voice_ip machine_id etc

machine_id=
default_voice_port=9987
voice_ip=
licensepath=
filetransfer_port=30033
filetransfer_ip=
query_port=10011
query_ip=0.0.0.0, ::
query_ip_whitelist=query_ip_whitelist.txt
query_ip_blacklist=query_ip_blacklist.txt
dbplugin=ts3db_sqlite3
dbpluginparameter=
dbsqlpath=sql/
dbsqlcreatepath=create_sqlite/
dbconnections=10
logpath=logs
logquerycommands=0
dbclientkeepdays=30
logappend=0
query_skipbruteforcecheck=1
query_buffer_mb=20
http_proxy=
license_accepted=0
serverquerydocs_path=serverquerydocs/
query_ssh_ip=0.0.0.0, ::
query_ssh_port=10022
query_protocols=raw,ssh
query_ssh_rsa_host_key=ssh_host_rsa_key
query_timeout=300

Hmm… it should.

Back to the ini file:

  • machine_id can be ignored
  • voice can be 0.0.0.0 if there’s one public network interface only
    (for IPv4 & IPv6: 0.0.0.0, ::)

If you don’t use an external database like MariaDB for example the config is fine.

Just change the value of license_accepted to 1 or your server won’t start.

1 Like

I launch it by this

./ts3server_minimal_runscript.sh inifile=ts3server.ini

and the page still stops downloading data from teamspeak after 5 refreshs for some time (probably 5 minutes).

Could you try to investigate a little bit further, please?

Speaking about 5 minutes may sounds like a timeout.
Or do 5 refreshs cause the rate limit?
I’m don’t know if the node package is up to date.

You could try to create a loop and send a textmessage each second for example (to yourself).
To test if you get ratelimited or not.

(edit)

We haven’t talked about the whitelist yet.

Please check my answer in this thread:

1 Like

Today I went to my website and everything works fine (what a suprise!). (Maybe except for one funny thing like no query disconnection, so I had query armies attached to teamspeak xD, but already fixed)
Thank you for help!

Problem Solved

2 Likes
twitch instagram twitter facebook