Jump to content


Photo

The bot goes offline while checking inventory

node.js node-steam-tradeoffer-manager

  • Please log in to reply
1 reply to this topic

#1 PonyExpress

PonyExpress

    Advanced Member

  • Member
  • PipPipPip
  • 35 posts

Posted 11 September 2019 - 03:52 PM

I have a function that runs on average about 2 minutes.

console.log(currentTime() + " START");
  community.getSteamUser...
    if (DATA.onlineState == "online"...
      let trade = manager.createOffer...
      manager.getUserInventoryContents...
        for (let i in BotSets.BaseSets) {.... }
        for (let i in BotSets.FoilSets) {.... }

// ----------------------------

        INV = INV.filter((ITEM) => ITEM.getTag("item_class").internal_name == "item_class_2");
console.log(currentTime() + " TEST, STEP 05-A");
        INV = INV.filter((ITEM) => ITEM.market_hash_name.indexOf("470480-Messenger") == -1);
        for (let i = 0; i < INV.length; i++) {
if (i == 5000) console.log(currentTime() + " TEST, ITEMS CHECKED: 5,000");
if (i == 40000) console.log(currentTime() + " TEST, ITEMS CHECKED: 40,000");
if (i == 50000) console.log(currentTime() + " TEST, ITEMS CHECKED: 50,000");
if (i == 60000) console.log(currentTime() + " TEST, ITEMS CHECKED: 60,000");
if (i == 70000) console.log(currentTime() + " TEST, ITEMS CHECKED: 70,000");
if (i == 80000) console.log(currentTime() + " TEST, ITEMS CHECKED: 80,000");
if (i == 90000) console.log(currentTime() + " TEST, ITEMS CHECKED: 90,000");
if (i == 100000) console.log(currentTime() + " TEST, ITEMS CHECKED: 100,000");
if (i == 110000) console.log(currentTime() + " TEST, ITEMS CHECKED: 110,000");
          if (amount < CONFIG.LIMITS.MAXTRANSFERCARDS && !idList.includes(INV[i].assetid)) {
            trade.addMyItem(INV[i]);
            amount++;
          } else if (amount == CONFIG.LIMITS.MAXTRANSFERCARDS && !idList.includes(INV[i].assetid)) {
            reachedLimit = true;
            break;
          }
        }
console.log(currentTime() + " TEST, STEP 05-B");

// ----------------------------

        trade.send((ERR) => { ....

In the end, I get:

23:24 START
23:25 TEST, STEP 05-A
23:25 TEST, ITEMS CHECKED: 5,000
23:25 TEST, ITEMS CHECKED: 40,000
23:26 TEST, ITEMS CHECKED: 50,000
23:26 TEST, ITEMS CHECKED: 60,000
23:26 TEST, ITEMS CHECKED: 70,000

// >> here I see that the bot goes offline

23:26 TEST, ITEMS CHECKED: 80,000
23:26 TEST, ITEMS CHECKED: 90,000
23:27 TEST, STEP 05-B
23:27 Error: HTTP error 401
23:27 client.steamID: null
23:27 (WAIT FOR RECONECT)
23:27 An error occurred while sending trade offer: Error: Not Logged In
23:27 (Login...)

Sometimes this function works, about 50/50%, but lately very often the bot goes offline before the trade offer is sent.

 

Are there any tips, how can I prevent the bot from shutting down while this function is running?



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,212 posts

Posted 11 September 2019 - 10:50 PM

So this is happening because JavaScript is single-threaded, and your loop is taking too long. While the loop is running, the rest of the code can't keep the connection to Steam alive and do other housekeeping tasks. You'll need to figure out a way to get the time that loop takes down, perhaps by limiting how many items it will process at a time, or perhaps by using setImmediate periodically so the rest of the event loop can get processed.







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

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users