sipeed/picoclaw · error

failed to listen on

Error message

failed to listen on %s: %w

What it means

Fired at the start of MaixCamChannel.Start when net.Listen cannot bind the configured host:port TCP address (port in use, invalid address, or missing permission). The channel cancels its context and refuses to start, since it cannot accept MaixCam device connections.

Solutions

  1. Check whether another process already holds the configured port (e.g. a previous instance still running)
  2. Change the maixcam port configuration or free the port
  3. Verify the configured host address is a valid local interface
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/channels/maixcam/maixcam.go:64 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/1849287a2e4b0035. Report an issue: GitHub.

Appendix: source

Thrown at pkg/channels/maixcam/maixcam.go:64

	)

	return &MaixCamChannel{
		BaseChannel: base,
		config:      cfg,
		clients:     make(map[net.Conn]bool),
	}, nil
}

func (c *MaixCamChannel) Start(ctx context.Context) error {
	logger.InfoC("maixcam", "Starting MaixCam channel server")

	c.ctx, c.cancel = context.WithCancel(ctx)

	addr := fmt.Sprintf("%s:%d", c.config.Host, c.config.Port)
	listener, err := net.Listen("tcp", addr)
	if err != nil {
		c.cancel()
		return fmt.Errorf("failed to listen on %s: %w", addr, err)
	}

	c.listener = listener
	c.SetRunning(true)

	logger.InfoCF("maixcam", "MaixCam server listening", map[string]any{
		"host": c.config.Host,
		"port": c.config.Port,
	})

	go c.acceptConnections()

	return nil
}

func (c *MaixCamChannel) acceptConnections() {
	logger.DebugC("maixcam", "Starting connection acceptor")

View on GitHub (pinned to 49183d7e8d)