Jump to content


Photo
Question

sessionExpired being called for no reason ?

node.js node-steamcommunity

  • Please log in to reply
6 replies to this topic

#1 DentFuse

DentFuse

    Newbie

  • Member
  • Pip
  • 7 posts
  • LocationIndia

Posted 12 March 2018 - 12:57 PM

Hi all, So this is my code :

community.on('sessionExpired', (err) =>{
  console.log("Session Expired !! Logging In Again...")
  if (a = 1) {
    a = 0
		login();
  }
});
community.on('disconnected', (err) =>{
  console.log("Disconnected !! Logging In Again...")
  if (a = 1) {
    a = 0
		login();
  }
});

So what is happening is that the sessionExpired is being called but when the bot is trying to log in, it crashes with an error stating that we are already logged in and we cannot log in again, also sometimes the bot crashes with an error saying the session was replaced or something like that, sorry I don't exactly remember, will post log when it happens again.

 

Any help would be greatly appreciated :)

 

PS: I've added that var a to make sure that the login function is called only once, I change it back to 1 once we get the webapi key from steam.



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,187 posts

Posted 13 March 2018 - 11:15 AM

It's being called for a reason, and that reason is that your session expired.

 

I assume that you're getting your session from node-steam-user, and you're calling logOn when it expires. That's wrong, you should call webLogOn.


  • DentFuse likes this

#3 DentFuse

DentFuse

    Newbie

  • Member
  • Pip
  • 7 posts
  • LocationIndia

Posted 14 March 2018 - 09:34 AM

It's being called for a reason, and that reason is that your session expired.

 

I assume that you're getting your session from node-steam-user, and you're calling logOn when it expires. That's wrong, you should call webLogOn.

 

Hey there! Thanks for your reply, so do you mean to say that I don't have to log in again when the session expires, but just call webLogOn(which gets a new session from steam? That's what I understood when I was reading the docs of node-steam-community)So all I have to do is replace my login function with a call to webLogOn ?

 

PS: I knew it was being called because our session expired, but wasn't sure why it was not logging in again...



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,187 posts

Posted 14 March 2018 - 04:11 PM

Correct. When you're using steam-user, your "login" is a connection to the CM. It's completely distinct from your web session. When your web session expires but you're still connected you don't need to reconnect. Just get a new web session which requests new cookies from the CM.



#5 DentFuse

DentFuse

    Newbie

  • Member
  • Pip
  • 7 posts
  • LocationIndia

Posted 15 March 2018 - 09:20 PM

Correct. When you're using steam-user, your "login" is a connection to the CM. It's completely distinct from your web session. When your web session expires but you're still connected you don't need to reconnect. Just get a new web session which requests new cookies from the CM.

 

Now I get error saying that we must be logged in steam before we can login in steamcommunity.com. Should I call my login func before webLogOn ?



#6 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,187 posts

Posted 16 March 2018 - 01:50 PM

Yes, you do need to login once.



#7 DentFuse

DentFuse

    Newbie

  • Member
  • Pip
  • 7 posts
  • LocationIndia

Posted 24 March 2018 - 12:30 PM

Okay so update on my bot, couldn't get the sessionExpired thing working,tried .relog(), .webLogOn(), .LogOn(), still couldn't get it working, so I just attached the bot to forever, so like when ever it crashes due to sessionExpired, it just restarts it. Happens once a day, so that's not much of a problem, but yeah, thanks you for answers :)

PS: I'll still try to get it working ;P





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

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users