I run geth with this command

geth --syncmode "fast" --cache 2048 --datadir /data/ethereum --ws --wsaddr --wsorigins '*' --wsapi 'web3,eth,net,db,personal' --rpc --rpcaddr

then i subscribe newHeads and recieve {"jsonrpc":"2.0","id":1,"result":"0x30ebfd74dc99548d16b64d23eda6f964"}.But can not recieve any block head.I try to connect infura wss://mainnet.infura.io/ws and recieve new block head.

import websocket
import json
import time
    import thread
except ImportError:
    import _thread as thread

def on_message(ws, message):

def on_error(ws, error):

def on_close(ws):
    print("### closed ###")

def on_open(ws):
    def run(*args):
        ws.send(json.dumps({"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}))
        print("thread terminating...")
    thread.start_new_thread(run, ())

if __name__ == "__main__":
    # ws = websocket.WebSocketApp("wss://mainnet.infura.io/ws",
                              on_message = on_message,
                              on_error = on_error,
                              on_close = on_close)
    ws.on_open = on_open

Am I wrong ? My geth version is Geth/v1.9.6-stable-bd059680/linux-amd64/go1.13.1.


1 Answer 1


Please check whether your Geth node is completely synced

  • only full sync support subscribe?
    – egodcore
    Commented Oct 30, 2019 at 5:57
  • no, Fast sync will support subscription, what I just meant is to check whether the node synced completely or not?
    – Akshay Dev
    Commented Oct 30, 2019 at 7:44
  • oh, i checkecd that the node synced completely. But steel can not recieve response
    – egodcore
    Commented Oct 30, 2019 at 8:47
  • try this on your terminal -- > wscat -c "ws://127.0.01:8546" then > {"jsonrpc":"2.0", "id": 1, "method": "eth_subscribe", "params": ["newHeads"]}
    – Akshay Dev
    Commented Oct 30, 2019 at 9:37
  • 1
    sorry, I checked sync again. The node is not synced completely...
    – egodcore
    Commented Oct 31, 2019 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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