Returned error: project ID request rate exceeded despite below 100k usage

Hi, I am trying to call getTransaction with web3 whenever I run my script I get rate limit exceeded error

Error: Returned error: project ID request rate exceeded
   .....
  data: {
    rate: {
      allowed_rps: 50,
      backoff_seconds: 30,
      current_rps: 80.86666666666666
    },
    see: 'https://infura.io/docs/ethereum/json-rpc/ratelimits'
  }
}

I looked at my dashboard I only used up 12k calls so I am wondering why this is happening. How do I solve this issue?

Hello,

Welcome to the community !
Are you calling it in a loop ? Would help to see the code you’re running.

Thanks,
Traian

I am currently using this script to watch out specific address on every tx

this.subscription.on('data', (txHash) => {
            setTimeout(async () => {
                try {
                    let tx = await this.web3.eth.getTransaction(txHash);
                    if (tx != null) {    
                      if (this.account == tx.to && tx.to != null) {
                        console.log({addressTo: tx.to, value: this.web3.utils.fromWei(tx.value, 'ether'), gas: tx.gas, timestamp: new Date()});
                      }
                    }
                } catch (err) {
                    console.error(err);
                }
            }, 30000)
        });

I’m not sure what you can do other than backing off. Are you subscribing for pendingTransactions ?
Also does it work with a higher timeout than 30000 ?

Thanks,
Traian

Ya i am subscribing to pending transactions and same result even on creasing the timeout, tho only shows up after timeout

hi @overlapjho - There are two issues here. The daily request limit is part of the equation; the other is the requests per second. As you can see in the error message, the free account is able to send up to 50 rps. Your code is bursting very heavily at 80.66 rps; you’ll need to slow down the requests you’re making to be able to have it work. Alternatively, you can subscribe to a paid plan, which will up that request limit.

Does the subscribe request per transaction returned?

I’m not sure I understand your question, sorry! Subscribing to a paid plan will increase the number of rps you are able to send.

is there any info about how many rps allowed on each plan?
also i mean that i only call the function once and not on the loop so i am not sure how do infura count the rps, is it based on each response of a request or based on how much the request is called?

Yes - all paid users are at 300 rps, and the count is based on the number of requests sent.