Bheem Posted May 1, 2016 Report Posted May 1, 2016 Hi, I am using node-steamcommunity to login and then pass the cookies to node-steam-tradeoffer-manager. Whenever session expires, I relogin and pass the cookies to tradeoffer manager: community.on('sessionExpired', function(err) { community.login(logOnOptions,function(err,sessionID,cookies,steamguard) { if(err) { connectRetry-=1; if(connectRetry==0) { connectRetry=5; setTimeout(function(){logger.info("Couldn't reach server, will log in after 30 min");logIn();},1000*60*30); // try again after 30 minutes } } fs.writeFile(homeDir+'data/steamguard.txt', steamguard); logger.info("Logged into Steam"); connectRetry=5; //use steamcommunity cookies for tradeoffer-manager manager.setCookies(cookies, function(err) { if (err) { logger.error(err); process.exit(1); return; } logger.info("Got API key: " + manager.apiKey); }); community.chatLogon(); //Log on to the chat so that bot appears online community.startConfirmationChecker(10000,secrets.identity_secret); //poll every 10 seconds and confirm }); }); Sometimes I get the following error: info: Logged into Steam C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\index.js:212 cookies.forEach(function(cookie) { ^ TypeError: Cannot read property 'forEach' of undefined at SteamCommunity.setCookies (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\index.js:212:9) at TradeOfferManager.setCookies (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steam-tradeoffer-manager\lib\index.js:80:18) at C:\MyData\education\NodeJsTutorial\steam-trade-bot\tradingBot.js:344:11 at SteamCommunity.<anonymous> (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\index.js:128:5) at Request._callback (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\components\http.js:62:14) at Request.self.callback (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\node_modules\request\request.js:200:22) at emitTwo (events.js:87:13) at Request.emit (events.js:172:7) at Request.<anonymous> (C:\MyData\education\NodeJsTutorial\steam-trade-bot\node_modules\steamcommunity\node_modules\request\request.js:1067:10) at emitOne (events.js:82:20) The error is coming on the line manager.setCookies(). Am I handling it in the wrong way or is this some bug? Thanks & Regards,Bheem Quote
timgfx Posted May 1, 2016 Report Posted May 1, 2016 (edited) When you log in you won't have the cookies yet. It's emitted on a websession <-- this is for steam-user, not steamcommunity. This is how I did it with steam-user, I will look into steamcommunity and try to fix it for you var SteamUser = require('steam-user'); var client = new SteamUser(); client.logOn(login); client.on('webSession', function(sessionID, cookies) { community.setCookies(cookies); manager.setCookies(cookies); community.startConfirmationChecker(10000, '*'); }); EDIT: Idk how to do it with steamcommunity. I would recommend logging in with steam-user and then setting the cookies for steamcommunity and steam-tradeoffer-manager like I did. Easiest thing for me. Good luck! Edited May 1, 2016 by timgfx Quote
Bheem Posted May 1, 2016 Author Report Posted May 1, 2016 Hi timgfx, In steamcommunity, cookies are returned with login. Please refer to the following link:https://github.com/DoctorMcKay/node-steamcommunity/wiki/SteamCommunity#logindetails-callback My bot works fine on login. Its just that sometimes when session expires and I re login, the following problem occurs. Quote
timgfx Posted May 1, 2016 Report Posted May 1, 2016 Hi timgfx, In steamcommunity, cookies are returned with login. Please refer to the following link:https://github.com/DoctorMcKay/node-steamcommunity/wiki/SteamCommunity#logindetails-callback My bot works fine on login. Its just that sometimes when session expires and I re login, the following problem occurs.Is there a possibily to do something like this: https://www.npmjs.com/package/steam-user#weblogon. Quote
Dr. McKay Posted May 1, 2016 Report Posted May 1, 2016 You're not returning in your if (err) block, so it'll continue as if nothing was wrong if there was a logon error. Quote
Bheem Posted May 4, 2016 Author Report Posted May 4, 2016 Thank you Dr. McKay. Don't know how i missed that. Quote
Recommended Posts
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.