Jump to content
McKay Development

Issue to relog for bot, especially on tuesday maintenance


nikoF

Recommended Posts

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

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

Link to comment
Share on other sites

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? 

Link to comment
Share on other sites

  • 2 weeks later...

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