Jump to content


Photo

Issue to relog for bot, especially on tuesday maintenance

node.js node-steam-user

  • Please log in to reply
10 replies to this topic

#1 nikoF

nikoF

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 18 May 2017 - 03:18 PM

18.05.2017 02:11:25  - HTTP error 503
## Session Expired. Relogging.
C:\Users\Administrator\Desktop\SteamBot\node_modules\steam-user\components\web.j
s:9
                throw new Error("Cannot log onto steamcommunity.com without firs
t being connected to Steam network");
                ^
 
Error: Cannot log onto steamcommunity.com without first being connected to Steam
 network
    at SteamUser.webLogOn (C:\Users\Administrator\Desktop\SteamBot\node_modules\
steam-user\components\web.js:9:9)
    at SteamCommunity.community.on (C:\Users\Administrator\Desktop\SteamBot\Test
asDynamic.js:300:12)
    at emitOne (events.js:96:13)
    at SteamCommunity.emit (events.js:191:7)
    at SteamCommunity._notifySessionExpired (C:\Users\Administrator\Desktop\Stea
mBot\node_modules\steamcommunity\components\http.js:85:7)
    at C:\Users\Administrator\Desktop\SteamBot\node_modules\steamcommunity\compo
nents\confirmations.js:21:10
    at C:\Users\Administrator\Desktop\SteamBot\node_modules\steamcommunity\compo
nents\confirmations.js:268:4
    at SteamCommunity._checkHttpError (C:\Users\Administrator\Desktop\SteamBot\n
ode_modules\steamcommunity\components\http.js:90:3)
    at Request._callback (C:\Users\Administrator\Desktop\SteamBot\node_modules\s
teamcommunity\components\http.js:50:61)
    at self.callback (C:\Users\Administrator\Desktop\SteamBot\node_modules\reque
st\request.js:188:22)
 

 

 

So this is the error from console.

When my session expires, I use this code to come back on track:

 

community.on('sessionExpired', (ERR) => {
console.log("## Session Expired. Relogging.");
client.webLogOn();
});

 

Not sure if it synced with this code, but I will write it too

client.on('webSession', function (sessionID, cookies) {
manager.setCookies(cookies, function (err) {
if (err) {
console.log(dateFormat(Date(), "dd.mm.yyyy HH:MM:ss ") + " - " + err);
//process.exit(1); I commented this cause I don't want to stop the node immediately
client.webLogOn(); // I put this in order to do webLogon again, not sure if necessary
return;
}
});

community.setCookies(cookies);
community.chatLogon();
community.startConfirmationChecker(config.steam.refreshInterval, config.steam.secret);
if (config.social.hasToUpdateProfile) {
updateProfile();
}
});

 

 

So yeah, any ideas how to solve this problem, and not get my node getting down after this Error("Cannot log onto steamcommunity.com without firs

t being connected to Steam network"); ?
 
Thank you in advance!
 
One solution would be to use forever npm, but I would like to hear other opinions how I could rework the code, to not make the node go off, because I'm not up to use that npm due to some variables being saved while bot is being up.


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,282 posts

Posted 18 May 2017 - 04:26 PM

You're trying to relog the web session while Steam is down. Don't do that, and just wait for Steam to come back. It will emit webSession automatically once it reconnects successfully.



#3 nikoF

nikoF

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 18 May 2017 - 04:48 PM

Is this part wrong? 

 

client.webLogOn(); // I put this in order to do webLogon again, not sure if necessary

 

Cause it doesn't get into this part tho as I see, because of the console.log() before that line which I am not able to see in the console.

 

Or you are talking about SessionExpired part? My mind is messed up at the moment. :( 



#4 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,282 posts

Posted 18 May 2017 - 05:24 PM

That's the correct method to use, but you can't use it if you aren't currently connected to Steam (e.g. because Steam is down). That's what's throwing that error.



#5 nikoF

nikoF

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 19 May 2017 - 01:53 AM

so how am I able to not go into that method, if I get an error when steam is down? 

 

SteamUser.prototype.webLogOn = function() {
    // Verify logged on
    if (!this.steamID) {
        throw new Error("Cannot log onto steamcommunity.com without first being connected to Steam network");
    }

    // Verify not anonymous user
    if (this.steamID.type != SteamID.Type.INDIVIDUAL) {
        throw new Error('Must not be anonymous user to use webLogOn (check to see you passed in valid credentials to logOn)')
    }

    this._send(SteamUser.EMsg.ClientRequestWebAPIAuthenticateUserNonce, {});
};

 

 

should I put something like emit on the first if condition?

Or you got some different ideas how to solve the problem? 



#6 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,282 posts

Posted 19 May 2017 - 07:47 PM

If Steam is down, you can't log in. I don't understand where the confusion is. Wait for Steam to come back online, and the client will reconnect on its own and emit webSession.



#7 nikoF

nikoF

    Newbie

  • Member
  • Pip
  • 4 posts

Posted 20 May 2017 - 12:37 AM

The confusion is, that if I'm sleeping at that time or not near my PC, and if the steam goes down, then the node on vpn goes down too at that time,so the bot will remain offline till I start the node again.



#8 samki

samki

    Newbie

  • Member
  • Pip
  • 6 posts

Posted 29 May 2017 - 02:07 PM

Just check if your steam client got a SteamID before webLogOn

	if (this._client.steamID !== null) {
		this._client.webLogOn();
	}


#9 Royalgamer06

Royalgamer06

    Member

  • Member
  • PipPip
  • 28 posts

Posted 01 June 2017 - 08:22 AM

Sorry to hijack this thread, but speaking of web session. I'm using pretty much the same code as above. But my purpose is to post to my friend activity, which I am doing like this:
    var profileurl = "http://steamcommunity.com/";
    if (vanityname) {
        profileurl += "id/" + vanityname;
    } else {
        profileurl += "profiles/" + client.steamID.getSteamID64();
    }
    var formdata = new Object();
    formdata.sessionid = community.getSessionID();
    formdata.appid = SOMEAPPID;
    formdata.status_text = SOMEMESSAGE;
    setTimeout(function() {
        community.httpRequestPost(profileurl + "/ajaxpostuserstatus/", {
            formData: formdata,
            followAllRedirects: true
        }, function(error, response, data) {
            var success, json;
            try {
                json = JSON.parse(data);
                success = json.success;
            } catch (e) {
                success = false;
            }
            console.log(response.statusCode, success);
            if (error) {
                console.log(error);
            }
        });
    }, 1000);
 
This all works fine when I recently login. All friend activity posts will return "200 True", but after a while it only returns "200 False". I suspect the web session has expired or something, but how can that be when I use the same code as above? Any other solutions maybe? Maybe somehow refresh web session each time I want to post something, but how?

Edited by Royalgamer06, 01 June 2017 - 08:26 AM.


#10 Royalgamer06

Royalgamer06

    Member

  • Member
  • PipPip
  • 28 posts

Posted 03 June 2017 - 11:21 AM

So, is there any way to refresh the web session with callback?

#11 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,282 posts

Posted 03 June 2017 - 06:58 PM

webLogOn() and wait for the webSession event.







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

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users