Jump to content


Photo

How can i trigger sessionExpired every 15 mins?

node.js node-steamcommunity

  • Please log in to reply
2 replies to this topic

#1 Riya

Riya

    Newbie

  • Member
  • Pip
  • 6 posts

Posted 28 December 2018 - 12:10 AM

my bot is getting web session expired and i use 

community.on('sessionExpired', function(err) {
if (err) {
console.log('sessionExpired: '+err);
} 
if (client.steamID) {
client.webLogOn();
} else {
client.logOn(logon_details);
}
});

this code is triggered when the user of bot tried to make the bot start a trade offer.

what is a simple way for me to trigger session expired like every 15 mins if the session has expired?

Ans- A simple http request every 15 mins using node-cron to trigger it. (i am not a coder so if u could show it to me thanks!)

 

Right now the user of bot triggers it then has to wait 1-2 mins then the bot webLogon() and then  sends trade offer

 

Alternative 2

it was suggested in forum

we can use direct cronschedule that does webLogOn() every 15 min , and whenever that error fires I also do a webLogOn().  but idk what will happen if i try to webLogON() if the session hasnt been expired yet thats y i wanted to set up Alternative 1


Edited by Riya, 28 December 2018 - 12:12 AM.


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,070 posts

Posted 28 December 2018 - 12:22 AM

Alternative 2

it was suggested in forum

we can use direct cronschedule that does webLogOn() every 15 min , and whenever that error fires I also do a webLogOn().  but idk what will happen if i try to webLogON() if the session hasnt been expired yet thats y i wanted to set up Alternative 1

 

There is absolutely nothing wrong with doing this. I'd recommend that you do it this way, although maybe 15 minutes is too quick. Try 30 minutes and if you still have trouble, lower it to 15.



#3 Riya

Riya

    Newbie

  • Member
  • Pip
  • 6 posts

Posted 28 December 2018 - 01:53 AM

thanks i ll post if this works out for me!

require('console-stamp')(console, '[HH:MM:ss.l]');
var cron = require('node-cron');

 
cron.schedule('*/30 * * * *', () => {
  client.webLogOn()
  console.log('weblogged in after 30 mins using cron')
});

Edited by Riya, 28 December 2018 - 02:06 AM.






Also tagged with one or more of these keywords: node.js, node-steamcommunity

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users