I use the following code to subscribe to the infura wss to retrieve pendingTransactions in real time. However I don’t receive realtime pending transactions anymore. Every new txHash that I receive belongs to a transaction that is on average 40 seconds to a minute old and is already confirmed in 1+ blocks.
…
this.subscription = this.web3ws.eth.subscribe(pendingTransactions, (err, res) => {
if (err) console.error(err);}
…
this.subscription.on(‘data’, (txHash) => { setTimeout(async () => {
try {
let tx = await this.web3.eth.getTransaction(txHash);
…
I tried the same method a few days ago and managed to get real time pending transactions however since 2 days this does not work anymore. The code is 100 % identical to what I used a few days ago. Is it possible that the infura websocket is lagging behind, or perhaps the subscribe function is not synced or something?