benjamin-wilson / public-pool-ui

28 stars 28 forks source link

cannot connect ui to public-pool api #17

Open warioishere opened 2 weeks ago

warioishere commented 2 weeks ago

the title states the problem. Everything runs on the same system. Public-pool runs fine and is already connected with my bitaxe

But ui doesnt seem to get a connection to the public-pool

my .env of public pool:

# bitcoin node running in your private network 192.168.1.0/24
#BITCOIN_RPC_URL=http://172.16.1.58

# bitcoin node running undockered on the same PC
# needs to add rpcallowip=172.16.0.0/12 to your bitcoin.conf
BITCOIN_RPC_URL=http://host.docker.internal

BITCOIN_RPC_USER=xxx
BITCOIN_RPC_PASSWORD=xxx
BITCOIN_RPC_PORT=8332
BITCOIN_RPC_TIMEOUT=10000

# You can use this instead of BITCOIN_RPC_USER and BITCOIN_RPC_PASSWORD
#BITCOIN_RPC_COOKIEFILE=

# Enable in bitcoin.conf with
# zmqpubrawblock=tcp://*:3000
BITCOIN_ZMQ_HOST="tcp://172.16.1.58:3000"

API_PORT=3334
STRATUM_PORT=3333

#optional telegram bot
#TELEGRAM_BOT_TOKEN=

#optional discord bot
#DISCORD_BOT_CLIENTID=
#DISCORD_BOT_GUILD_ID=
#DISCORD_BOT_CHANNEL_ID=

#optional
DEV_FEE_ADDRESS=
# mainnet | testnet
NETWORK=mainnet

API_SECURE=false

my enviroment.prod.ts:

export const environment = {
    production: true,
    API_URL: 'http://host.docker.internal:32793',
    STRATUM_URL: 'blitzpool.yourdevice.ch:32792'
};

my docker-compose-yml of the public pool:

version: '3.8'

services:
  public-pool:
    container_name: public-pool
    build:
      context: .
      dockerfile: Dockerfile
    restart: unless-stopped
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "32792:3333"
      - "32793:3334"
    volumes:
      - "./${NETWORK}-DB:/public-pool/DB"
      - "./.env:/public-pool/.env:ro"
    environment:
      - NODE_ENV=production

the docker command I am using to setup public-pool-ui:

docker run --name public-pool-ui -d -p 8081:80 -e DOMAIN=public-pool.yourdevice.ch public-pool-ui

any idea? the docker logs of the public-ui continer doesnt show any useful informations

remcoros commented 2 weeks ago

The API_URL should be a public IP or hostname, not the internal docker host.

Your browser needs to be able to reach that API_URL.

warioishere commented 2 weeks ago

The API_URL should be a public IP or hostname, not the internal docker host.

Your browser needs to be able to reach that API_URL.

Thanks, fixed it partially with internal IP of the host. But the public-pool-ui still looses connection randomly to the public-pool api

It can also be an internal IP address right?

public-pool.yourdrvice.ch is the address

I am not at home and need to check again later

remcoros commented 2 weeks ago

the UI is a full client-side (browser) app. So all API calls go from your browser directly to the public-pool API. You need open the API port to the world and use the public IP (or hostname) so your browser can make the API calls.

You can see if it works by opening the Network tab of your browsers dev tools, and inspect the requests to e.g. "/network". It should respond with some network info JSON.

warioishere commented 2 weeks ago

the UI is a full client-side (browser) app. So all API calls go from your browser directly to the public-pool API. You need open the API port to the world and use the public IP (or hostname) so your browser can make the API calls.

You can see if it works by opening the Network tab of your browsers dev tools, and inspect the requests to e.g. "/network". It should respond with some network info JSON.

Yes i made it to work and of course the API port is opened to the WAN. It worked this morning, now checked again on your pool and the public-pool-ui doesnt get any infos anymore from the API of the public-pool Backend

Need to See this evening what is going on