Categories
Cryptocurrency Ethereum Mastering Development

MetaMask custom RPC connection error with private ganache-cli, EC2

Currently I am trying to build private dapp using ganache-cli as a blockchain backend with aws ec2 instance.

I get the expected result from terminal.

request:

curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' localhost:8545

response:

{"id":67,"jsonrpc":"2.0","result":"EthereumJS TestRPC/v2.10.2/ethereum-js"}

However, I get following error when I set up MetaMask’s custom rpc like: {MY_PUBLIC_IP}:8545 even though my ganache docker (and ipfs) is running.
Is there anything that I am missing?

inpage.js:1 MetaMask - RPC Error: JsonRpcEngine: Response has no error or result for request:
{
  "id": 1852126408,
  "jsonrpc": "2.0",
  "method": "eth_chainId",
  "params": [],
  "origin": "{MY_PUBLIC_IP_HERE}"
} 

WebSocket connection to 'ws://{MY_PUBLIC_IP_HERE}/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT

and here is my docker-compose setting:

version: "3"
services:
  ganache:
    image: trufflesuite/ganache-cli:latest
    ports:
      - "127.0.0.1:8545:8545"
      - "127.0.0.1:8546:8546"
    entrypoint:
    - node
    - /app/ganache-core.docker.cli.js
    - --deterministic
    - --db=/ganache_data
    - --mnemonic
    - 'minimum symptom minute gloom tragic situate silver mechanic salad amused elite beef'
    - --hostname
    - '0.0.0.0'
    restart: always
  ipfs:
    build: ./ipfs
    ports:
      - "127.0.0.1:4001:4001"
      - "127.0.0.1:4002:4002/udp"
      - "127.0.0.1:5001:5001"
      - "127.0.0.1:8080:8080"
      - "127.0.0.1:8081:8081"
    restart: always

Leave a Reply

Your email address will not be published. Required fields are marked *