hkp Posted April 9, 2023 Report Posted April 9, 2023 I occasionally get this error after my program runs for 12-24 hours. I only have 3 different calls to the logOn method and they are all in this format: client.logOff(); setTimeout(function() { if(client.steamID) return; client.logOn({ accountName: 'username', password: 'password', twoFactorCode: SteamTotp.generateAuthCode(sharedSecret), logonID: parseInt(111111111 * Math.random()) }) }, 5000) I read on other posts regarding this error that the logOn should be delayed after the logOff is called and that if client.steamID exists, it means it should already be logged in so I return when the steamID property exists. This hasn't solved my error and I still receive this which exits the process. E:\projects\steambot\node_modules\steam-user\components\logon.js:23 throw new Error("Already logged on, cannot log on again"); ^ Error: Already logged on, cannot log on again at E:\projects\steambot\node_modules\steam-user\components\logon.js:23:10 at processTicksAndRejections (node:internal/process/task_queues:77:11) What would be my best solution to fix this error? I don't think wrapping the logOn calls in a try-catch block would be sufficient but I could be wrong. Quote
Dr. McKay Posted April 9, 2023 Report Posted April 9, 2023 A better way to accomplish this would be to watch for the disconnected event: client.logOff(); client.once('disconnected', () => { // logged off; now safe to log on again }); Quote
hkp Posted April 9, 2023 Author Report Posted April 9, 2023 (edited) 10 hours ago, Dr. McKay said: A better way to accomplish this would be to watch for the disconnected event: client.logOff(); client.once('disconnected', () => { // logged off; now safe to log on again }); I can't seem to find anything regarding the 'once' I already have the logOff & logOn happening inside .on('disconnected') how is once different? Can I use it like this inside of the error, disconnected and loggedOff event handlers? client.on('error', function(e) { if (e.eresult === SteamUser.EResult.LoggedInElsewhere) { err("[STEAM] This account is already logged in elsewhere - Attempting to re-login."); } else if ( e.eresult === SteamUser.EResult.RateLimitExceeded ) { err("[STEAM] Steam is currently rate-limiting our connection - Attempting to re-login."); } else { err(`[STEAM] An error occurred: ${e.message} - Attempting to re-login.`); } client.logOff(); client.once('disconnected', () => { //logged off; now safe to log on again. client.logOn({ accountName: 'hgcwa834', password: 'rUSTCASINO888!', twoFactorCode: SteamTotp.generateAuthCode(sharedSecret), logonID: Math.random() * 100000000 }) }); }) Edited April 9, 2023 by hkp Quote
hkp Posted April 11, 2023 Author Report Posted April 11, 2023 I have wrapped every call to logOn apart from the one that occurs on start up in .once('disconnected') but I still get that same error E:\projects\steambot\node_modules\steam-user\components\logon.js:23 throw new Error("Already logged on, cannot log on again"); ^ Error: Already logged on, cannot log on again at E:\projects\steambot\node_modules\steam-user\components\logon.js:23:10 at processTicksAndRejections (node:internal/process/task_queues:77:11) Quote
Dr. McKay Posted April 11, 2023 Report Posted April 11, 2023 https://nodejs.org/api/events.html#emitteronceeventname-listener I dunno what to tell you; it seems like you've got some kind of concurrency problem or something. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.