Skip to content

c8y-remote-access-plugin retries connecting to mqtt broker forever if unreachable #3660

@reubenmiller

Description

@reubenmiller

Describe the bug

If the c8y-remote-access-plugin is started in an independent environment (e.g. in a container), and fails to connect to the MQTT broker (so it can retrieve a token), then it never gives up, and is in a continuous retry loop (see log exert below).

This scenario can occur when thin-edge.io is used in a container context, e.g. tedge-container-bundle, where a new container is spawned to run the c8y-remote-access-plugin binary, but if the container networking is not configured correctly, then the container never stops, which results in using more device resources.

2025-05-29T11:27:36.127406603Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:37.15013544Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:38.173000276Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:39.195281959Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:40.217935153Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:41.242957772Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:42.26310246Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:43.284203995Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve
2025-05-29T11:27:44.304746377Z ERROR MQTT: Failed to connect to broker at 'objective_heyrovsky:1883': I/O: failed to lookup address information: Name does not resolve

To Reproduce

Reproducing this is a little tricky, but roughly involves the following steps:

  1. Configure a thin-edge.io instance using the tedge-container-bundle, but don't configure the container to join the "tedge" bridge network

  2. Create a Cumulocity Cloud Remote Access PASSTHROUGH configuration to connect to port 22 (for SSH), and the target server host should be the docker gateway IP address, e.g. 172.17.0.1.

  3. Try to connect the remote access client to the PASSTHROUGH configuration using go-c8y-cli

    c8y remoteaccess connect ssh --device mydevice --user root --configuration <config_name>

Expected behavior

The c8y-remote-access-plugin should exit with a non-zero exit code (along with an error message), if it is unable to successfully get a Cumulocity token, whether it be from not being able to connect to the MQTT broker, or if not JWT is received.

Screenshots

Environment (please complete the following information):

  • OS [incl. version]: Linux
  • Hardware [incl. revision]: any
  • System-Architecture [e.g. result of "uname -a"]: any
  • thin-edge.io version [e.g. 0.1.0]: 1.5.1

Additional context

  • Allow passing the JWT via environment variables (since the token is not valid for very long, this might be an ok option)

  • How to handled basic auth, as now JWT is available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtheme:c8yTheme: Cumulocity related topicstheme:troubleshootingTheme: Troubleshooting and remote control

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions