Skip to content

Unable to connect to broker #716

Open
@zaklabs

Description

@zaklabs

I have installed netmaker v0.22.0 with docker-compose.yml like below:

`version: "3.4"

services:
netmaker:
container_name: netmaker
image: gravitl/netmaker:v0.22.0
cap_add:
- NET_ADMIN
- NET_RAW
- SYS_MODULE
sysctls:
- net.ipv4.ip_forward=1
- net.ipv4.conf.all.src_valid_mark=1
- net.ipv6.conf.all.disable_ipv6=0
- net.ipv6.conf.all.forwarding=1
restart: always
env_file: .env
volumes:
- dnsconfig:/root/config/dnsconfig
- sqldata:/root/data
- mosquitto_data:/etc/netmaker
environment:
SERVER_NAME: "broker.${NETMAKER_BASE_DOMAIN}:1883"
SERVER_HOST: "${SERVER_PUBLIC_IP}"
SERVER_API_CONN_STRING: "api.${NETMAKER_BASE_DOMAIN}:443"
COREDNS_ADDR: "${SERVER_PUBLIC_IP}"
DNS_MODE: "on"
SERVER_HTTP_HOST: "api.${NETMAKER_BASE_DOMAIN}"
API_PORT: "8081"
CLIENT_MODE: "on"
MASTER_KEY: "${NETMAKER_MASTER_KEY}"
CORS_ALLOWED_ORIGIN: "*"
DISPLAY_KEYS: "on"
DATABASE: "sqlite"
NODE_ID: "netmaker-server-1"
HOST_NETWORK: "off"
VERBOSITY: "1"
MANAGE_IPTABLES: "on"
PORT_FORWARD_SERVICES: "dns"
SERVER_BROKER_ENDPOINT: "10.1.0.4:1883"
MQ_USERNAME: "${MQ_USERNAME}"
MQ_PASSWORD: "${MQ_PASSWORD}"
ports:
- "51821-51830:51821-51830/udp"
- "8081:8081"
networks:
app-network:
ipv4_address: 10.1.0.5
backend:
ipv4_address: 172.18.0.9

netmaker-ui:
container_name: netmaker-ui
image: gravitl/netmaker-ui:v0.22.0
depends_on:
- netmaker
links:
- "netmaker:api"
env_file: .env
restart: always
environment:
BACKEND_URL: "https://api.${NETMAKER_BASE_DOMAIN}"
networks:
app-network:
backend:
ipv4_address: 172.18.0.8

coredns:
container_name: coredns
image: coredns/coredns:1.10.1
command: -conf /root/dnsconfig/Corefile
depends_on:
- netmaker
restart: always
volumes:
- dnsconfig:/root/dnsconfig
networks:
app-network:

mq:
container_name: mq
image: eclipse-mosquitto:latest #2.0.18
depends_on:
- netmaker
env_file: .env
restart: unless-stopped
command: ["/mosquitto/config/wait.sh"]
networks:
app-network:
ipv4_address: 10.1.0.4
backend:
ipv4_address: 172.18.0.10
ports:
- "1883:1883"
environment:
NETMAKER_SERVER_HOST: "https://api.${NETMAKER_BASE_DOMAIN}"
# NETMAKER_SERVER_HOST: "10.1.0.197"
volumes:
- ./config/mosquitto.conf:/mosquitto/config/mosquitto.conf
- ./config/wait.sh:/mosquitto/config/wait.sh
- mosquitto_data:/mosquitto/data
- mosquitto_logs:/mosquitto/log

#Docker Networks
networks:
app-network:
external: true
backend:
external: true

#Volumes
volumes:
sqldata:
driver: local
name: sqldata_netmaker
driver_opts:
type: none
device: /home/zfuadi/repo/netmaker/data_netmaker/netmaker_sqldata
o: bind
dnsconfig:
driver: local
name: coredns_netmaker
driver_opts:
type: none
device: /home/zfuadi/repo/netmaker/data_netmaker/netmaker_dnsconfig
o: bind
mosquitto_data:
driver: local
driver_opts:
type: none
device: /home/zfuadi/repo/netmaker/netmaker_mosquitto_data
o: bind
mosquitto_logs:
driver: local
driver_opts:
type: none
device: /home/zfuadi/repo/netmaker/netmaker_mosquitto_logs
o: bind
`
The server work normally. but when i run netclient via docker in other host, I got this error as shown as log below:

[netclient] 2024-02-19 16:57:40 MQ client is not connected, using fallback checkin for server broker.zone139.zaklabs.my.id:1883
[netclient] 2024-02-19 16:57:46 unable to connect to broker, retrying ...
[netclient] 2024-02-19 16:57:46 unable to connect to broker, retrying ...
[netclient] 2024-02-19 16:57:46 unable to connect to broker, retrying ...
{"time":"2024-02-19T16:57:46.045461483Z","level":"ERROR","source":"daemon.go 264}","msg":"unable to connect to broker","server":"","error":"status can only transition to connecting from disconnected"}
{"time":"2024-02-19T16:57:46.045787048Z","level":"ERROR","source":"mqhandlers.go 425}","msg":"unable to connect to broker","server":"","error":"status can only transition to connecting from disconnected"}

What missing with my configuration ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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