neverhood Posted February 1, 2019 Report Posted February 1, 2019 (edited) Hello, I released some donation/trash bot and most of time everything is working fine, processing a lot of trades without any problems (only accepting gift trades), but lately I got weird problem, session expiring 1 second after new trade my console logs: [18:35:09] - Processing trade 3459285622 [18:35:10] Session expired - relogging [21:56:28] - Processing trade 3459471951 [21:56:29] Session expired - relogging how I handle it in my bot: const community = new SteamCommunity(); const manager = new SteamTradeofferManager({ steam: client, language: 'en', community }); community.on('sessionExpired', () => { console.log(`[${new Date().toLocaleTimeString()}] Session expired - relogging`); client.webLogOn(); });everything works good, but sometimes getting this error and my bot stuck (should I remove community from manager?) edit: I noticed I wrongly used community in const manager Edited February 1, 2019 by neverhood Quote
Dr. McKay Posted February 1, 2019 Report Posted February 1, 2019 edit: I noticed I wrongly used community in const manager Does this mean it's fixed? Quote
neverhood Posted February 1, 2019 Author Report Posted February 1, 2019 I changed it to community: community, and I will test (need a few hours to test it) Quote
Dr. McKay Posted February 1, 2019 Report Posted February 1, 2019 The way you used community in your first post is correct. You can do just {community} which is interpreted as {community: community}. I think probably what's happening is that your session is just expiring (which happens normally) and you aren't expecting it. It wouldn't hurt to add an automatic hourly webLogOn call to be more proactive about renewing your session rather than reactive. Quote
neverhood Posted February 2, 2019 Author Report Posted February 2, 2019 The way you used community in your first post is correct. You can do just {community} which is interpreted as {community: community}. I think probably what's happening is that your session is just expiring (which happens normally) and you aren't expecting it. It wouldn't hurt to add an automatic hourly webLogOn call to be more proactive about renewing your session rather than reactive. I have no idea why this is happening randomly (when someone send trade offer session getting expired 1 second after and my bot stuck), sometimes my bot works even 72 hours without this issue, I think maybe because bot is idling for longer time (not receving any trade offer) this is happening. Quote
Dr. McKay Posted February 2, 2019 Report Posted February 2, 2019 I have no idea why this is happening randomly (when someone send trade offer session getting expired 1 second after and my bot stuck) I think you might be misunderstanding what's happening. Your session isn't expiring immediately after someone sends you a trade offer. The module can only know that your session expired if it attempts to make a cookie-authenticated request and it fails. The module knows that you got a new trade offer from the API (which doesn't expire), but when you try to act on it that takes place on steamcommunity.com so that's the earliest you can know that your session expired. Exactly what causes a session to expire is known only to God Valve, and you'll just need to work around it by refreshing your session as needed. Quote
neverhood Posted February 2, 2019 Author Report Posted February 2, 2019 now I get it (I think so ), thank you for explaining me should I add setInterval in 'loggedOn' with 1 hour refresh? something like this: setInterval(function(){ client.webLogOn(); }, 3600000); my current code: client.on('webSession', (sessionID, cookies) => { manager.setCookies(cookies); const f = Object.keys(client.myFriends); for (let i = f.length - 1; i >= 0; i--) if (client.myFriends[f[i]] === 2) client.addFriend(f[i]); }); client.on('loggedOn', () => { client.gamesPlayed(configuration.gamesPlayed); client.setPersona(1); console.log(`[${new Date().toLocaleTimeString()}] - ONLINE - ${client.steamID.getSteamID64()}`); });am I setting properly manager cookies with every websession? Quote
Dr. McKay Posted February 2, 2019 Report Posted February 2, 2019 Yes, that would work. For clarity's sake, you should use SteamUser.EPersonaState.Online instead of 1 and SteamUser.EFriendRelationship.RequestRecipient instead of 2 in that code. 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.