DoctorMcKay / node-steamcommunity

Interact with various interfaces on Steam Community from Node.js
https://dev.doctormckay.com/forum/8-node-steamcommunity/
MIT License
481 stars 129 forks source link

offer confirm callback not being called (stuck) #245

Closed jd1378 closed 4 years ago

jd1378 commented 4 years ago

offers were getting confirmed quickly without any problem till recently ( like 3 days ago) then suddenly community.acceptConfirmationForObject() no longer calls the callback anymore on random trades occasionally and causes my bot to freeze completely

DoctorMcKay commented 4 years ago

Show your code, please.

jd1378 commented 4 years ago
// community is `'steamcommunity'` instance and is logged in.
function confirmOffer(offerId) {
  return new Promise((resolve, reject) => {
    console.log(`Confirming Offer #${offerId}`);
    community.acceptConfirmationForObject(
      identitySecret,
      offerId,
      (confirmErr) => {
        if (confirmErr) {
          console.log(confirmErr);
          return reject(confirmErr);
        }
        return resolve(true);
      }
    );
  });
}

After Confirming Offer #${offerId} being logged, the promise never resolves, so the only way it could happen is that the callback is never fired. As I said it was working fine until recently and I haven't had make any changes to the code.

jd1378 commented 4 years ago

Also now i noticed that my bot is getting this error when getting active offers recently {"code":"ESOCKETTIMEDOUT","connect":false}

// somewhere manager = new TradeOfferManager(...)
function getActiveOffersCountPromise() {
  return new Promise((resolve, reject) => {
    manager.getOffers(
      EOfferFilter.ActiveOnly,
      null,
      (err, sentOffersByMe, receivedOffersByMe) => {
        if (err) {
          console.log(
            `Error while counting active offers: ${JSON.stringify(err)}`
          );
          return reject(err);
        }
        return resolve(sentOffersByMe.length + receivedOffersByMe.length);
      }
    );
  });
}
jd1378 commented 4 years ago

Tell me if more info is needed

DoctorMcKay commented 4 years ago

Have you passed a timeout option to the SteamCommunity constructor?

jd1378 commented 4 years ago

No, It's using the defaults but it takes forever instead of 50 seconds

jd1378 commented 4 years ago

I'm logging in to SteamCommunity using disableMobile: true, does it have anything to do with this ? Edit: Apparently not.

jd1378 commented 4 years ago

can it happen if steam has blacklisted our ip from using their apis ?

jd1378 commented 4 years ago

even node-steam-user is not logging in , and it does not raise any error ! I suspect there is a bug where under some special condition like this nothing happens with your packages, no event, no login, no error ....

jd1378 commented 4 years ago

@DoctorMcKay And I'm sure of it works on local dev env, but not on our specific server (which was working till some time ago)

DoctorMcKay commented 4 years ago

Sounds like a problem with your server's network or something else. Such a big in both modules would be highly improbable, as they connect to Steam in completely different ways.

jd1378 commented 4 years ago

either way , why wouldn't the library dispatch error event on the case of network error ?

DoctorMcKay commented 4 years ago

That's a good question, one I can't answer. I suspect something is weird in your OS and it isn't enforcing timeouts properly.

jd1378 commented 4 years ago

I did a bit of debugging and used 'debug' event to check if it is actually logging in or not and it seems it does login successfully, but the webSession event is never emitted, even if I use webLogOn() manually on the node user (I am logging in using account name and password so there isn't any need for this, but I wanted to confirm)

DoctorMcKay commented 4 years ago

Sounds like your server has some real problems with HTTP requests, at least to Steam. Web logons go through the Steam WebAPI (api.steampowered.com).

jd1378 commented 4 years ago

Thanks a lot for pointing out the domain name (api.steampowered.com) and possible problem with http, I just did a quick check on my server and the problem is indeed with the server's dns settings, It seems that somehow the dns servers it had was pointing to wrong ips. it was a really weird problem, but thanks for taking your time to answer, I couldn't figure it out without your help

DoctorMcKay commented 4 years ago

Glad you got it sorted.