4

My geth verison is :

  ./geth version
Geth
Version: 1.5.8-unstable

and run geth with the command below:

 ./geth --identity "helloworld"   --ws  --wsaddr 192.168.241.128 --wsport 8545  --rpc  --rpcaddr 192.168.241.128 --rpcport 8545 --rpccorsdomain "*"   --datadir "$basepath/chain" --port "30303"  --rpcapi "db,eth,net,ssh,miner,web3,personal,admin" --networkid 88888 console

and typed command below in another console:

curl 192.168.241.128:8545 -X POST --data '{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}'
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"notifications not supported"}}

when I typed command changed the port to 8546:

curl 192.168.241.128:8546 -X POST --data '{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}'
bad method

I found from https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB : From version 1.4 geth has experimental support for pub/sub using subscriptions as defined in the JSON-RPC 2.0 specification. This allows clients to wait for events instead of polling for them.

So my geth version is higer than 1.4, So what's the problem?? Thank you.

0

I found that in the ethereum document that: subscriptions require a full duplex connection. Geth offers such connections in the form of websockets (enable with --ws) and ipc (enabled by default).

so it must obey the websockets rule,so

curl 192.168.241.128:8545 -X POST --data '{"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}',

it is a http rule, and 8545 isn't websocket ports ,it must be 8546. And it we notice the 2 points above , we will communicate with it successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.