What Comes Around Posted May 10, 2021 Report Posted May 10, 2021 (edited) C:\Users\Ernest\Desktop\SteamBot\node_modules\steam-user\components\web.js:10 throw new Error("Cannot log onto steamcommunity.com without first being connected to Steam network"); ^ Error: Cannot log onto steamcommunity.com without first being connected to Steam network at SteamUser.webLogOn (C:\Users\Ernest\Desktop\SteamBot\node_modules\steam-user\components\web.js:10:9) at SteamCommunity.<anonymous> (C:\Users\Ernest\Desktop\SteamBot\components\steamclient.js:73:20) at SteamCommunity.emit (events.js:315:20) at SteamCommunity._notifySessionExpired (C:\Users\Ernest\Desktop\SteamBot\node_modules\steamcommunity\components\http.js:85:7) at C:\Users\Ernest\Desktop\SteamBot\node_modules\steamcommunity\components\confirmations.js:21:10 at C:\Users\Ernest\Desktop\SteamBot\node_modules\steamcommunity\components\confirmations.js:272:4 at SteamCommunity._checkHttpError (C:\Users\Ernest\Desktop\SteamBot\node_modules\steamcommunity\components\http.js:90:3) at Request._callback (C:\Users\Ernest\Desktop\SteamBot\node_modules\steamcommunity\components\http.js:50:61) at self.callback (C:\Users\Ernest\Desktop\SteamBot\node_modules\request\request.js:185:22) at Request.emit (events.js:315:20) Function that triggers it: client.logOn({ accountName: username, password: password, rememberPassword: true, twoFactorCode: SteamTotp.generateAuthCode(shared_secret), }); client.on('loggedOn', ()=> { isLoggedOn = true; client.setPersona(1); log.debug('LoginClient', `Client logged in ${user.username}`) if(hasWebSession) resolve(); }) client.on('webSession', (sid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); hasWebSession = true; log.debug('LoginClient', `Client weblogged in ${user.username}`) if(isLoggedOn) resolve(); }) client.on('error', (err) => { log.error('LoginClient', `Client experienced an error ${user.username}`) log.error('LoginClient', err) }) community.on('sessionExpired', () => { log.info('LoginClient', `${user.username}'s websession expired!`) client.webLogOn(); }) community.on('sessionExpired', () => { log.info('LoginClient', `${user.username}'s websession expired!`) client.webLogOn(); }) Here is an error I am getting when checking for an expired session. Would it be possible to prevent this? I mean I think I could do something along the lines of try catching weblogOn, but do you perhaps have a better solution? Edited May 10, 2021 by What Comes Around Quote
Dr. McKay Posted May 11, 2021 Report Posted May 11, 2021 Before you call webLogOn, check to see if the client.steamID property is null. If it is, then you're not connected to Steam, and that's likely the reason why your web session expired. What Comes Around 1 Quote
What Comes Around Posted May 11, 2021 Author Report Posted May 11, 2021 31 minutes ago, Dr. McKay said: Before you call webLogOn, check to see if the client.steamID property is null. If it is, then you're not connected to Steam, and that's likely the reason why your web session expired. Perfect! Thank you! 48 minutes ago, Dr. McKay said: Before you call webLogOn, check to see if the client.steamID property is null. If it is, then you're not connected to Steam, and that's likely the reason why your web session expired. Also if I use the logOn() function, by default the webLogOn function is called too, right? Quote
Dr. McKay Posted May 11, 2021 Report Posted May 11, 2021 Correct, when a new client session is established, a web session is automatically negotiated. What Comes Around 1 Quote
What Comes Around Posted May 29, 2021 Author Report Posted May 29, 2021 On 5/11/2021 at 12:31 PM, Dr. McKay said: Correct, when a new client session is established, a web session is automatically negotiated. I get this error from time to time: (node:31740) UnhandledPromiseRejectionWarning: Error: Already logged on, cannot log on again at C:\Users\Ernest\Desktop\Current Version\node_modules\steam-user\components\logon.js:23:10 at processTicksAndRejections (internal/process/task_queues.js:75:11) (node:31740) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3) Sometimes my bot experiences this error maybe times in a row. Worst case scenario I've seen it reoccur 100 times. Any idea what could be the cause of this issue? I found this while looking at the steam user npm: https://www.npmjs.com/package/steam-user#events-. At steamGuard I can see that you mention: "If you are using 2FA, you need to check the lastCodeWrong argument. If it's true, then the last code you provided was incorrect (likely already used). In this case, you should wait 30 seconds to allow the TOTP algorithm to generate a new code. Failure to do so will result in a login loop, causing your IP address to be temporarily banned.". Could this be the cause of the error? Quote
Dr. McKay Posted June 2, 2021 Report Posted June 2, 2021 That error happens when you call logOn while the SteamUser instance is already connected. What Comes Around 1 Quote
What Comes Around Posted June 2, 2021 Author Report Posted June 2, 2021 (edited) 4 hours ago, Dr. McKay said: That error happens when you call logOn while the SteamUser instance is already connected. That's strange. Because based on my code I don't see how this should occur. Below I will include the only code that should relogin the user. community.on('sessionExpired', () => { log.info('LoginClient', `${user.username}'s websession expired!`) if (client.steamID == null) { log.info('LoginClient', `${user.username} was disconnected from steam! Relogging in.`) client.logOn({ accountName: username, password: password, rememberPassword: true, twoFactorCode: SteamTotp.generateAuthCode(shared_secret), }); } else { client.webLogOn(); } }) Let me know if you see anything wrong with this. Because unless client.steamID doesn't always return the correct login status, I don't see why this error should occur. Also, I should mention that before the code above was introduced, I wasn't getting the "already logged in" error. Edit: Thinking about it now, perhaps the issue is that when I log in via client.logOn I replace the session, and because I have relog turned on, it relogs in, causing this loop. Because I am getting 1000s of relogins and the Replaced Session error pops up as well. So if I had to guess that's the cause, and the fix would be to just not call logOn, let it do it's thing but once client.steamID is ! null,call client.webLogOn(). Anyways, that's just me guessing. I'd like to hear your thoughts on what's happening. Edited June 2, 2021 by What Comes Around Quote
Dr. McKay Posted June 2, 2021 Report Posted June 2, 2021 If you haven't disabled automatic reconnection, then you shouldn't ever need to call logOn after the first time (unless the error event gets emitted). So yeah, when you get sessionExpired just check to make sure SteamUser is connected, then call webLogOn() if it is. If it isn't, then it'll automatically log onto web when it gets connected. What Comes Around 1 Quote
What Comes Around Posted June 3, 2021 Author Report Posted June 3, 2021 (edited) On 6/2/2021 at 8:22 PM, Dr. McKay said: If you haven't disabled automatic reconnection, then you shouldn't ever need to call logOn after the first time (unless the error event gets emitted). So yeah, when you get sessionExpired just check to make sure SteamUser is connected, then call webLogOn() if it is. If it isn't, then it'll automatically log onto web when it gets connected. Also, are the events 'loggedOn' and 'disconnected' directly tied to the state of client.steamID? Also, is client.steamID an accurate indicator of the client being connected? If I had to guess, client.steamID is returned by steam and is nullified when the connection is broken, and when the ID is returned (Client is connected) or there is a disconnection those events are emitted. Is my assumption correct? Edited June 3, 2021 by What Comes Around Quote
Dr. McKay Posted June 5, 2021 Report Posted June 5, 2021 On 6/3/2021 at 2:58 PM, What Comes Around said: Also, are the events 'loggedOn' and 'disconnected' directly tied to the state of client.steamID? Yes. On 6/3/2021 at 2:58 PM, What Comes Around said: Also, is client.steamID an accurate indicator of the client being connected? Yes. On 6/3/2021 at 2:58 PM, What Comes Around said: If I had to guess, client.steamID is returned by steam and is nullified when the connection is broken, and when the ID is returned (Client is connected) or there is a disconnection those events are emitted. Is my assumption correct? That's correct. client.steamID gets set just before loggedOn is emitted (meaning it's not null once you connect), and gets set to null just after disconnected / error are emitted. What Comes Around 1 Quote
What Comes Around Posted June 5, 2021 Author Report Posted June 5, 2021 5 hours ago, Dr. McKay said: Yes. Yes. That's correct. client.steamID gets set just before loggedOn is emitted (meaning it's not null once you connect), and gets set to null just after disconnected / error are emitted. Perfect, thank you very much! Dr. McKay 1 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.