starwolfy / steam-ts

Steam integration for TeamSpeak 3
MIT License
62 stars 9 forks source link

Teamspeak v3.7.0 - { id: 513, msg: 'nickname is already in use' } #29

Open Forge-Media opened 5 years ago

Forge-Media commented 5 years ago

Nickname error

I've just updated my Teamspeak 3 to version 3.7.0 I can no longer get Steam-TS to start. Each time I get the following error:

{ id: 513, msg: 'nickname is already in use' }

I'm currently having to rename the bot in the launchteamspeak.js file each time, i.e: Steam-Bot1, Steam-Bot2.

This works, but only as long as the bot does not crash. As as soon as it does, and PM2 restarts it, it gets the above error that the bot's nickname is already in use.

Unfortunately, the Steam-TS bot crashes quite a lot, hence why I launch it via PM2. The cause of the crashing appears to be:

Random Crashes

Seeing the same error as above, even after the fix #9b3a358

Error: Callback was already called.
    at /home/ts3bot/steam-ts/node_modules/async/dist/async.js:837:34
    at Object.cb (/home/ts3bot/steam-ts/lib/queryusers.js:49:29)
    at LineInputStream.<anonymous> (/home/ts3bot/steam-ts/node_modules/node-teamspeak/index.js:170:35)
    at LineInputStream.emit (events.js:182:13)
    at LineInputStream.line (/home/ts3bot/steam-ts/node_modules/line-input-stream/lib/line-input-stream.js:8:8)
    at Array.forEach (<anonymous>)
    at Socket.<anonymous> (/home/ts3bot/steam-ts/node_modules/line-input-stream/lib/line-input-stream.js:36:9)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)

PM2 lists this error 7 times, and also shows it's restarted the steam-ts bot 7 times, so concluding that this error is causing it to crash.

Forge-Media commented 5 years ago

I noticed you've made some updates recently so I reinstalled the bot with the latest version.

Unfortunately I'm noticing the same error as above.

Launch the bot once: npm start and then stop the bot, then try restart it and I get:

{ id: 513, msg: 'nickname is already in use' }

Even though no user has that nickname.

Forge-Media commented 5 years ago

For now I've solved this by the following "hack" change to launchteamspeak.js :

function (teamspeakClient, callback) {
            console.log("Using virtual server " + config.q_vserverid + " now.");
            var rnum = Math.floor(Math.random() * Math.floor(1000));
            teamspeakClient.send("clientupdate", {client_nickname: "FGN-Steambot"+rnum}, function (err) {
                if (typeof err !== "undefined") {
                    callback(err);
                } else {
                    console.log("Changed query client name.");
                    callback(null, teamspeakClient);
                }
            })
        }

This avoids the error by effectively giving the bot a unique nickname every-time it connects. But it's a rather inelegant solution, and I'm not exactly sure why its required in the first place.

Interestingly I'm not noticing this issue on another bot, one I've personally created. However, in that case it's using a different Teamspeak 3 NodeJS library (TS3-NodeJS-Library), from the one used in this project (node-teamspeak)

Bealze commented 5 years ago

yes broken with latest ts server version

Forge-Media commented 5 years ago

@Bealze I've fixed this in a more elegant way than my above "hack random name" code.

You can find the code changes I've made here: 3e900e7

Bealze commented 5 years ago

i have tried to download your whole archive and run it but some reason it fails to load some issue with not a package.json format?

On Sat, Apr 13, 2019 at 2:14 PM Jeremy Paton notifications@github.com wrote:

@Bealze https://github.com/Bealze I've fixed this in a more elegant way than my above "hack random name" code.

You can find the code changes I've made here: 3e900e7 https://github.com/Forge-Media/steam-ts/commit/3e900e786c015d848cd69a2b54d5b1032c24dc13

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nikitavondel/steam-ts/issues/29#issuecomment-482856237, or mute the thread https://github.com/notifications/unsubscribe-auth/ACfSOpaEk9BDn-8jkrUshUo8sgXxFcDOks5vgh5qgaJpZM4cMB1Z .

MagicD3VIL commented 5 years ago

@Bealze I suggest downloading Forge-Media's whole fork. I just tested it out and it's working fine without any errors! https://github.com/Forge-Media/steam-ts