Skip to content

TCP mode in Docker image 2.7 fails to start due to PROMETHEUS_SERVER_PORT type (string vs int) #232

Description

@mammuthus

I’ve been trying to run meshtastic-prometheus-exporter:2.7 in TCP mode inside Docker and ran into a startup crash that looks like a bug in the current release.

Environment

  • Exporter: ghcr.io/hacktegic/meshtastic-prometheus-exporter:2.7
  • Deployment: Docker Compose (using the repo’s docker-compose.yml as a base)
  • Interface: MESHTASTIC_INTERFACE=TCP
  • Meshtastic node: Heltec V4, reachable over TCP at 192.168.27.233:4403
  • Host OS: Proxmox VM (Debian/Ubuntu‑like), Docker + docker compose

docker-compose.yml (relevant part)

services:
  exporter:
    image: ghcr.io/hacktegic/meshtastic-prometheus-exporter:2.7
    restart: unless-stopped
    environment:
      MESHTASTIC_INTERFACE: TCP
      INTERFACE_TCP_ADDR: 192.168.27.233
      INTERFACE_TCP_PORT: 4403
      PROMETHEUS_SERVER_ADDR: 0.0.0.0
      PROMETHEUS_SERVER_PORT: 9100
      LOG_LEVEL: info
    networks:
      - mesh-bridge

networks:
  mesh-bridge:
    driver: bridge

The Meshtastic TCP port is reachable from the host:

nc -vz 192.168.27.233 4403  
Connection to 192.168.27.233 4403 port [tcp/*] succeeded!

Inside the container the env looks correct (excerpt):

MESHTASTIC_INTERFACE=TCP  
INTERFACE_TCP_ADDR=192.168.27.233  
INTERFACE_TCP_PORT=4403  
PROMETHEUS_SERVER_ADDR=0.0.0.0  
PROMETHEUS_SERVER_PORT=9100  

Observed behavior

The container repeatedly restarts with the following log (shortened):

CRITICAL - Exception occurred while starting up:  
File `meshtastic_prometheus_exporter/__main__.py`, line 127:  
start_http_server(port=config["prometheus_server_port"], addr=config["prometheus_server_addr"])  

Deep down in `wsgiref.simple_server` / `socketserver.TCPServer.server_bind` this ends with:

TypeError: 'str' object cannot be interpreted as an integer

Because of this the HTTP server never starts, and the exporter never reaches the point where it connects to the Meshtastic TCP interface.

Code analysis

In __main__.py, configuration is built like this (simplified):

- `prometheus_server_addr` is read from `PROMETHEUS_SERVER_ADDR` (default `"127.0.0.1"`)
- `prometheus_server_port` is read from `PROMETHEUS_SERVER_PORT` (default `"9464"`)

Both are stored in the config dict as strings:

"prometheus_server_port": os.environ.get("PROMETHEUS_SERVER_PORT", "9464")
Later:

start_http_server(
    port=config["prometheus_server_port"],
    addr=config["prometheus_server_addr"],
)

Since os.environ.get always returns a string, config["prometheus_server_port"] is a string, but start_http_server expects an integer port, which explains the TypeError.

This happens regardless of whether the port is set via Docker env or left as default.

(Separately, TCP address/port are correctly picked up from INTERFACE_TCP_ADDR and INTERFACE_TCP_PORT.)

Expected behavior

  • Exporter should start the HTTP server on the configured port (PROMETHEUS_SERVER_PORT, default 9464) and then connect to the Meshtastic TCP interface.
  • Docker deployment with MESHTASTIC_INTERFACE=TCP and PROMETHEUS_SERVER_PORT=9100 should work out‑of‑the‑box.

Actual behavior

  • Exporter crashes on startup due to treating prometheus_server_port as string instead of integer.
  • This makes the official Docker‑based setup unusable in this configuration (at least for TCP, and likely for other interfaces as well) unless the code is patched.

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