sentanos / roblox-js

!!!THIS PROJECT IS NO LONGER MAINTAINED!!! Execute ROBLOX website actions in node.js
MIT License
45 stars 45 forks source link

ECONNRESET error emitted when there is a large delay between login & getPlayers #54

Closed Neztore closed 6 years ago

Neztore commented 7 years ago

I login with my account, which has no issues. As I wish to repeat the same action every ten minutes, there is a delay of 10 minutes. When the bot then attempts to getPlayers in my group, it returns a ECONNRESET error. This error is not caused when there is no delay. Full error:

      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at exports._errnoException (util.js:874:11)
    at TLSWrap.onread (net.js:544:26)

Code:

.then(function () {
  console.log(da + ' Logged in with account ' + username);

rank();
function rank() {
  setTimeout(function () {
console.log('Started!');  
var promise = rbx.getPlayers(groupID, getPlayersID);

console.log(da + ' Getting Players in rank ' + getPlayersID);
  promise.then(function (res) {
    var plrs = res.players;
if (plrs.length == 0) {return console.log('No Players to rank')}
for (i = 0; i < plrs.length; i ++) {
var d = new Date()
var da = '' + (d.getHours() + 1) + ':' + (d.getMinutes() + 1) + ':' + (d.getSeconds() + 1);
console.log(da + ' User ' + plrs[i].name + ' was ranked');
  rbx.setRank(groupID, plrs[i].id, RankTO)
  .then(function (newRole) {

  });

 }

  })
}, 600000)
}
});

If this is an issue with my code, I apologise greatly.

sentanos commented 7 years ago

This may be caused by enabling forever in the http function. After editing that file and removing line 16, does the error still occur?

Neztore commented 6 years ago

Error is now emitted for all actions - Removing Line 16 does not fix the issue.

sentanos commented 6 years ago

I cannot replicate the error. Running the exact code below works for me, please run it as well and let me know if it works.

var rbx = require('roblox-js');

rbx.login('username', 'password')
.then(function () {
  console.log('Logged in');
});

setTimeout(function () {
  console.log('Executing');
  rbx.getPlayers(2669445, 255).then(console.log);
}, 600000);

Although I am adding login to stay consistent with your issue, the reality is the getPlayers function does not log in at all. The cookie is not sent with requests because it is not needed and will speed up getting every page.

Neztore commented 6 years ago

After further investigation it appears this error is only present on one device which leads me to believe it is not a lib issue. Thanks for your help though.