Vizzy Posted June 10, 2021 Report Posted June 10, 2021 I've made a thread about this a few months ago but back then I managed to get it working. However, I now need to implement the same thing and I cannot get it to work. I'm simply trying to refresh the session after it has expired. I'm attempting this by manually invalidating the cookies, the event is never called. Code const SteamUser = require('steam-user'); const SteamCommunity = require('steamcommunity'); const SteamTotp = require('steam-totp'); const TradeOfferManager = require('steam-tradeoffer-manager'); const client = new SteamUser(); const community = new SteamCommunity(); const manager = new TradeOfferManager({ community: this.community, language: 'en', }); client.logOn({ ... }) client.on('loggedOn', () => { console.log('bot has logged into steam.'); client.setPersona(SteamUser.EPersonaState.Online); }); client.on('webSession', (session, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); console.log('websession established'); }); client.on('error', (err) => console.log(err)); community.on('sessionExpired', () => { console.log('session has expired'); }); setTimeout(function () { console.log('attempting to kill session'); community.setCookies(['sessionid=1||invalid', 'steamLogin=1||invalid', 'steamLoginSecure=1||invalid']); manager.setCookies(['sessionid=1||invalid', 'steamLogin=1||invalid', 'steamLoginSecure=1||invalid']); // make void call to trigger sessionExpired community.getNotifications((err, notifications) => console.log(err ? 'sessionExpired should be triggered now' : notifications)); }, 10 * 1000); What am I missing? I would presume after calling getNotifications (for testing purposes) the sessionExpired event would be fired. Quote
Dr. McKay Posted June 11, 2021 Report Posted June 11, 2021 There are a few different criteria that are checked when determining if an error warrants emitting the sessionExpired event. As a general rule, it gets emitted if a page redirects to /login. Valve being Valve, they're incredibly inconsistent as to how they communicate that you aren't logged in. The request for getting notifications returns 401, which isn't one of the criteria that emits sessionExpired. It probably should be, but I'll have to check to see if there are any other edge cases that might arise by adding 401 responses as an indicator to emit sessionExpired. Quote
Vizzy Posted June 12, 2021 Author Report Posted June 12, 2021 Okay, so getNotifications is not something that triggers sessionExpired? I'm currently having problems with running the tradebots 24 hours a day, 7 days a week. What would you suggest to achieve this? Quote
Dr. McKay Posted June 13, 2021 Report Posted June 13, 2021 For the most part, if you just call webLogOn every 30 minutes, you should be fine. Quote
Vizzy Posted June 13, 2021 Author Report Posted June 13, 2021 That's precisely what I'm currently doing, I guess my issue lays somewhere else then. 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.