ethereumproject / go-ethereum

Go language implementation of the original/classic design of the Ethereum protocol
GNU Lesser General Public License v3.0
442 stars 166 forks source link

The method eth_subscribe_newHeads does not exist/is not available #644

Closed feiyan-cs closed 5 years ago

feiyan-cs commented 6 years ago

Hello, I am scratching my head here, I am trying to integrate ETC with our exchange but I can't subscribe to newHeads or newPendingTransactions events. newHeads give me this error and newPendingTransactions mean while no error but no event is being triggered either.

I am using web3.js from https://github.com/ethereum/web3.js and my ETC geth start cmd is geth --rpcapi "all" --ws --wsaddr "0.0.0.0" --wsport "8546" --wsorigins "*" --chain=morden --fast --port "30304"

hao33828 commented 6 years ago

Could you specify which error newHeads event is throwing

feiyan-cs commented 6 years ago
Error: Returned error: The method eth_subscribe_newHeads does not exist/is not available
    at Object.ErrorResponse (/[MASKED]/node_modules/web3-core-helpers/src/errors.js:29:16)
    at Object.<anonymous> (/[MASKED]/node_modules/web3-core-requestmanager/src/index.js:140:36)
    at /[MASKED]/node_modules/web3-providers-ws/src/index.js:76:44
    at Array.forEach (<anonymous>)
    at W3CWebSocket.WebsocketProvider.connection.onmessage (/[MASKED]/node_modules/web3-providers-ws/src/index.js:53:36)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (/[MASKED]/node_modules/yaeti/lib/EventTarget.js:107:17)
    at W3CWebSocket.onMessage (/[MASKED]/node_modules/web3-providers-ws/node_modules/websocket/lib/W3CWebSocket.js:234:14)
    at WebSocketConnection.<anonymous> (/[MASKED]/node_modules/web3-providers-ws/node_modules/websocket/lib/W3CWebSocket.js:205:19)
    at emitOne (events.js:116:13)
    at WebSocketConnection.emit (events.js:211:7)
    at WebSocketConnection.processFrame (/[MASKED]/node_modules/web3-providers-ws/node_modules/websocket/lib/WebSocketConnection.js:547:26)
    at /[MASKED]/node_modules/web3-providers-ws/node_modules/websocket/lib/WebSocketConnection.js:321:40
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9) null Subscription {
whilei commented 6 years ago

@feiyan-cs I'm wondering where you found the reference for eth_subscribe_newHeads, or where you've used it before?

Noting that it's not cited in the following documents:

And the interface seems unavailable in ETH

INFO [07-11|07:20:55.415] UDP listener up                          self=enode://8a97cb8556ed03bb44a17cde3e15c7310f6c4ec3b14d67e1daac471302606d6df2d1da8328619367cb211fe4fd7d7079625c3a3e6fe0cbdb1908965de6727e23@71.226.173.63:30303
INFO [07-11|07:20:55.415] RLPx listener up                         self=enode://8a97cb8556ed03bb44a17cde3e15c7310f6c4ec3b14d67e1daac471302606d6df2d1da8328619367cb211fe4fd7d7079625c3a3e6fe0cbdb1908965de6727e23@71.226.173.63:30303
INFO [07-11|07:20:55.418] IPC endpoint opened                      url=/home/ia/.ethereum/geth.ipc
INFO [07-11|07:20:55.422] Mapped network port                      proto=tcp extport=30303 intport=30303 interface=NAT-PMP(10.0.1.1)
ReferenceError: 'eth_subscribe_newHeads' is not defined
    at <anonymous>:1:1

INFO [07-11|07:20:55.469] IPC endpoint closed                      endpoint=/home/ia/.ethereum/geth.ipc
INFO [07-11|07:20:55.469] Blockchain manager stopped 
INFO [07-11|07:20:55.469] Stopping Ethereum protocol 

, though the code does look available: https://github.com/ethereum/go-ethereum/blob/master/eth/filters/filter_system.go#L287

feiyan-cs commented 6 years ago

I am using the same code which is successful for ETH, but it doesn't work for ETC.

Am I missing anything? Not available on ETC?

feiyan-cs commented 6 years ago

Basically my code is using standard web3.js from https://github.com/ethereum/web3.js/

web3.eth.subscribe('newBlockHeaders', function(){/...../})

I am getting the same error when I call web3's web3.eth.sendSignedTransaction

aarthiKannanEY commented 5 years ago

Hi any resolution for this error? I am observing the same using dockerized geth with web3.

gabmontes commented 5 years ago

@whilei this is actually the response to a standard newHeads subscription attempt by web3 ({"id": 1, "method": "eth_subscribe", "params": ["newHeads"]}) which follows what is documented here too:

https://github.com/ethereumproject/go-ethereum/wiki/RPC-PUB-SUB#newheads

Is this actually implemented, despite it is documented in the wiki?