Skip to content

NewTestServer unreachable rpc address #216

@huahuayu

Description

@huahuayu

Env

Mac m1 macos 12.4
Docker Desktop 4.10.1

Issue

When run abi/encoding_test.go/TestEncoding(t *testing.T) function

The testsuit/server.go NewTestServer() created a geth client, but port 8545 can't be reached.

func (t *TestServer) HTTPAddr() string {
	return fmt.Sprintf("http://%s:8545", t.resource.Container.NetworkSettings.IPAddress)
}

Error screenshot

image

The docker container info

$ docker ps | grep ethereum
03e1459341a8   ethereum/client-go:v1.10.15   "geth --dev --datadi…"   8 minutes ago   Up 8 minutes   0.0.0.0:55020->8545/tcp, 0.0.0.0:55019->8546/tcp, 0.0.0.0:55006->30303/udp, 0.0.0.0:55018->30303/tcp   serene_ardinghelli

Inside the container the command is

geth --dev --datadir /eth1data --ipcpath /eth1data/geth.ipc --http --http.addr 0.0.0.0 --http.api eth,net,web3,debug --ws --ws.addr 0.0.0.0
--verbosity 4
$ifconfig
eth0      Link encap:Ethernet  HWaddr 02:42:AC:11:00:04
          inet addr:172.17.0.4  Bcast:172.17.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2006 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1378 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2466217 (2.3 MiB)  TX bytes:77013 (75.2 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:18 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1073 (1.0 KiB)  TX bytes:1073 (1.0 KiB)

$ telnet 172.17.0.4 8545
Connected to 172.17.0.4
Connection closed by foreign host

I think it's because of the wrong geth command, it's actually equivalent to using blew docker-compose.yml to start a geth client, the container can get up, but inside the container, telnet 127.0.0.1 8545, doesn't work.

version: '2'
services:
  geth:
    image: ethereum/client-go:v1.10.15
    command: --dev --datadir /eth1data --ipcpath /eth1data/geth.ipc --http --http.addr 0.0.0.0 --http.api eth,net,web3,debug --ws --ws.addr 0.0.0.0 --verbosity 4
    ports:
      - "30303:30303"
      - "30303:30303/udp"
      - "8545:8545"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions