Search code examples
ethereumgo-ethereumgeth

geth event newPendingTransactions does not occur


I've got running geth with next command:

$ geth --testnet --networkid 3 --verbosity 3 --syncmode light --ipcdisable --ws --wsapi "db,eth,net,web3,personal,txpool,admin,miner" --wsorigins '*'

In second console I connect to geth jsonrpc with wscat.

Subscribing to an event "newHeads" works fine:

$ wscat -c ws://localhost:8546
> {"id": 2, "method": "eth_subscribe", "params": ["newHeads"]}
< {"jsonrpc":"2.0","id":2,"result":"0x660135584e36a9edb0c55f89c389848"}
< {"jsonrpc":"2.0","method":"eth_subscription","params":{"subscription":"0x660135584e36a9edb0c55f89c389848","result":{"parentHash":"0xe7d0...","hash":"0x1dcc...

But subscribing to an event "newPendingTransactions" not works:

$ wscat -c ws://localhost:8546
> {"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}
< {"jsonrpc":"2.0","id":1,"result":"0x511b3274aa5dec44bb79d178c238e7fe"}

And it's all: I do not get new pending transactions.

Subscribing to an event "newPendingTransactions" on ropsten.infura.io works fine:

$ wscat -c wss://ropsten.infura.io/ws
> {"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}
< {"jsonrpc":"2.0","id":1,"result":"0x18fda7bf20ee9c5b5f1f08edf5c3e482"}
< {"jsonrpc":"2.0","method":"eth_subscription","params":{"subscription":"0x18fda7bf20ee9c5b5f1f08edf5c3e482","result":"0xc1e00266ab9f2c512d6c1967c300fc00381586e868611b7dff6fd94f230dd707"}}

Info:

$ geth version
Geth
Version: 1.8.22-stable
Git Commit: 7fa3509e2eaf1a4ebc12344590e5699406690f15
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.10.4
Operating System: linux
GOPATH=
GOROOT=/usr/lib/go-1.10

I have two questions:

1. Why subscribing to event "newPendingTransactions" not works?

2. What am I doing wrong?


Solution

  • The problem was that I did not wait for the end of synchronization.

    I started from scratch (this time i used Rinkeby network):

    geth --rinkeby --verbosity 3 --syncmode fast --ipcdisable --ws --wsapi "db,eth,net,web3,personal,txpool,admin" --wsorigins '*'
    

    For the Rinkeby network, this took about 20 hours and the size of the blockchain is about 25 gigabytes on my SSD.

    And now the subscribing for newPendingTransactions event works fine!

    Thanks all!