Jump to content
McKay Development

sessionExpired after trade notification


neverhood

Recommended Posts

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

now I get it (I think so :D), 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?

 

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...