Jump to content
McKay Development

Already logged on, cannot log on again


hkp

Recommended Posts

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.

Link to comment
Share on other sites

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 by hkp
Link to comment
Share on other sites

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)

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...