Jump to content


Photo

"Not logged in"

node.js node-steam-tradeoffer-manager

  • Please log in to reply
1 reply to this topic

#1 MrInka

MrInka

    Newbie

  • Member
  • Pip
  • 9 posts

Posted 20 April 2017 - 04:51 AM

Hey,  

I see that there are already topics discussing this particular error, but most of them aren't including code examples. Tried to fix it myself, but it doesn't seem to work.  

 

So when accepting an offer, I sometimes get this error:  

Error: Not Logged In
    at SteamCommunity._checkCommunityError (/home/pi/Desktop/bot_final/node_modules/steamcommunity/components/http.js:128:9)
    at Request._callback (/home/pi/Desktop/bot_final/node_modules/steamcommunity/components/http.js:51:88)
    at Request.self.callback (/home/pi/Desktop/bot_final/node_modules/steamcommunity/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/home/pi/Desktop/bot_final/node_modules/steamcommunity/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Gunzip.<anonymous> (/home/pi/Desktop/bot_final/node_modules/steamcommunity/node_modules/request/request.js:1001:12)
    at Gunzip.g (events.js:291:16)

So to log in, I am using this:  

var config = require('./config.js');
var SteamCommunity = require('steamcommunity');
var SteamTotp = require('steam-totp');
var SteamUser = require('steam-user');
var TradeOfferManager = require('steam-tradeoffer-manager');


var community = new SteamCommunity();
var client = new SteamUser();
var manager = new TradeOfferManager({
  steam: client,
  domain: 'example.com',
  language: 'en'
});

client.logOn({
    accountName: config.username,
    password: config.password,
    twoFactorCode: SteamTotp.generateAuthCode(config.sharedsecret)
});

client.on('loggedOn', function(details) {
  console.log("Bot logged in");
  client.setPersona(SteamUser.Steam.EPersonaState.Online,config.botname);
});

client.on('webSession', function(sessionID, cookies) {
  manager.setCookies(cookies, function(err) {
    if (err) return console.log(err);
    console.log(" > Got API key!");
  });
  community.setCookies(cookies);
  community.startConfirmationChecker(10000, config.identitysecret);
})

And to keep the bot from coming up with the "Not logged in error", I added this (which obviously doesnt work).  

var lastLoginAttempt = Date.now();

client.on("sessionExpired", function(err) {
    if(Date.now() - lastLoginAttempt > 30000) {
        lastLoginAttempt = Date.now();
        console.log(" > Session Expired, relogging.");
        client.webLogOn();
    } else {
        console.log(" Session Expired, waiting a while before attempting to relogin.");
    }
});

I was told to add a "timer" so it doesn't spam the login when the websession expires.

 

Any idea why it doesn't work? Is client.webLogOn() the right way to log in again?  

 

 

 

Any help is appreciated! :)

 
 

Edited by MrInka, 20 April 2017 - 08:42 AM.


#2 Dr. McKay

Dr. McKay

    Administrator

  • Administrator
  • 1,045 posts

Posted 20 April 2017 - 10:22 AM

Yes, client.webLogOn is the correct way to do it. I suspect that you're getting a new web session successfully (add some logging to the webSession event to make sure), and you're just doing something else wrong.







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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users