【问题标题】:how to curl to Ethereum geth node on local network (not localhost)如何卷曲到本地网络上的以太坊 geth 节点(不是本地主机)
【发布时间】:2020-07-16 16:16:17
【问题描述】:

我在本地网络(单独的机器)上运行 geth。卷曲到 http://localhost:8545 工作得很好。如何从我的专用网络上的另一台机器卷曲到该 geth 节点?卷曲到http://10.x.x.x:8545 只是返回连接被拒绝。

geth 本身在另一台 10.x.x.x 机器上运行良好,geth attach、curl 等都在该机器上的 localhost 上运行。

例如这行得通:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://localhost:8545

result: ➜  {"jsonrpc":"2.0","id":67,"result":"Geth/v1.9.17-unstable-5b081ab2-20200714/darwin-amd64/go1.13.6"}


this fails (from another machine on that private network):

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://10.x.x.x:8545

result ➜ curl: (7) Failed to connect to 10.x.x.x port 8545: Connection refused

(当然使用真实 IP 而不是 x)

另外两个节点都可以正常通信(ssh、浏览网站、文件共享等)

【问题讨论】:

    标签: curl geth


    【解决方案1】:

    您需要启用--rpcaddr 标志才能接受连接。从某处/任何地方,--wsaddr websocket 连接的标志。

    例子:

    $ geth --rpc --rpcaddr 0.0.0.0
    $ geth --rpc --wsaddr 0.0.0.0
    $ geth --rpc --rpcaddr 0.0.0.0 --wsaddr 0.0.0.0
    

    这允许您接受来自任何接口和网络的连接。您可以 geth attach、curl、web3 提供程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 2021-10-29
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多