-3

I have an issue with a SteamBot I have recently set up to handle deposits and winnings for a CS:GO Gambling site. It works well for depositing and sending trade offers for the first couple of minutes, before throwing me this error:

C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Parser.js:82
        throw err;
              ^
Error: number format error: empty string
    at Error (native)
    at Function.Long.fromString (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\node_modules\long\dist\Long.js:180:19)
    at toAccountId (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\index.js:376:15)
    at SteamTradeOffers.makeOffer (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\index.js:396:42)
    at Query._callback (C:\Users\Frederik\Desktop\bot\sell.js:160:13)
    at Query.Sequence.end (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
    at Query._handleFinalResultPacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Query.js:144:8)
    at Query.EofPacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Query.js:128:8)
    at Protocol._parsePacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Protocol.js:271:23)
    at Parser.write (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Parser.js:77:12)

I have searched everywhere for the solution to this, however haven't managed to find anything. Any help or solutions would be very much appreciated! I am unsure as to what piece of code may be causing the issue, so here is a pastebin with the whole lot of it: http://pastebin.com/x9YkhkCX

Alex Shesterov
  • 26,085
  • 12
  • 82
  • 103
  • Here's a hint, your error message is telling you very specific lines to look at. – user2366842 Sep 18 '15 at 20:56
  • You forgot something at `C:\Users\Frederik\Desktop\bot\sell.js:160:13` that is expected to be a string representing an account number at `C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\index.js:376:15`. – Kenney Sep 18 '15 at 21:01
  • @user2366842 I am not experienced at all within this area of programming. I've taken a look at every file and each line in which is stated, however am not seeing anything. – Joe Sharland Sep 18 '15 at 21:06
  • @Kenney Thanks! How would I go about fixing this exactly? – Joe Sharland Sep 18 '15 at 21:06
  • I'm sure you've overcome other obstacles while writing your bot, but okay. First understand what is going wrong, and then you will automatically know how to fix it. – Kenney Sep 18 '15 at 21:09
  • @Kenney That's the thing, I have no idea what is going wrong. – Joe Sharland Sep 18 '15 at 21:14

2 Answers2

0

Fixing it comes down to understanding what is going wrong. Once you know what is wrong, you automatically know the way it should be. Rather than saying exactly what needs to be changed to fix it, I hope to show you how to find out for yourself.

If this is the first time you've come across a stacktrace, here's how to read this one.

It starts like this:

C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Parser.js:82
        throw err;
              ^

a 'Parser' inside a mysql library throws an error; that tells you some SQL query is failing. Next it goes on to explain the err (^):

Error: number format error: empty string

The error is that a number is not formatted properly, because it is an empty string. It is like handing a function a blank piece of paper when it expects a number to be written onto it. But it isn't, so it doesn't know what to do, and raises an Error.

So now we know what is going wrong - at a low level. Let's see where it is going wrong, so that we know why.

We find this in the stacktrace: the function calls, all the way from the beginning of the program, to where the error was raised:

    at Error (native)

This first line says that this error orinates in an Error function at some place called 'native': somewhere within the execution environment (the javascript engine), not in the program being executed. This doesn't give us any new context - we know there is an error already.

    at Function.Long.fromString (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\node_modules\long\dist\Long.js:180:19)

Here, we get something related to numbers: it seems to be a function converting a string to a Long, which is a type of large number. Not much news here either, as the error message told us empty string already. But at least we are on the right track.

    at toAccountId (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\index.js:376:15)

Here we see that the number/string is probably an 'account id', used in the stream-tradeoffers module. For now let's assume that the empty string is passed to this function, and in the process of converting it to an account id it is turned into a number. Before we want to debug third party modules, lets first see if the problem is not in the main program:

    at SteamTradeOffers.makeOffer (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\index.js:396:42)

Again the library, followed by:

    at Query._callback (C:\Users\Frederik\Desktop\bot\sell.js:160:13)

In OP's pastebin we find at that line:

offers.makeOffer ({
    partnerSteamId: row[i].userid,
    itemsFromMe: item,
    accessToken: row[i].token,
    itemsFromThem: [],
    message: 'Congratulations! You won a game on '+sitename+'. Your game ID is #'+gamenum
}, function(err,response){....

Here we find the call to makeOffer, and what parameters are used. It is likely that one of them is the empty string, or is an object with an empty-string property that is read by the makeOffer method; to find out, we'd have to check files mentioned in the previous two stacktrace lines.

To save time, we don't really need to look at the rest of the stack trace, since from here on it only references the mysql library, and it's unlikely the problem is there:

    at Query.Sequence.end (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
    at Query._handleFinalResultPacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Query.js:144:8)
    at Query.EofPacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Query.js:128:8)
    at Protocol._parsePacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Protocol.js:271:23)
    at Parser.write (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Parser.js:77:12)
Kenney
  • 9,003
  • 15
  • 21
0

From my experience the issue comes from the mysql database, table games & row userid and row token as below.

partnerSteamId: row[i].userid

accessToken: row[i].token

The PHP script that executes executes the mysql_query doesn't execute it correctly so it doesn't enter any userid & token in the database if another database row is too big.

That's my theory.

Dave
  • 1