thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
221 stars 54 forks source link

Support connecting to Cumulocity using its IP and custom HTTP and MQTT ports #1834

Open albinsuresh opened 1 year ago

albinsuresh commented 1 year ago

Is your feature request related to a problem? Please describe.

Thin-Edge can not connect to a Cumulocity instance if the HTTPS and MQTTS ports exposed by it are different from the default ones (443 and 8883 respectively). It's not easy to connect to Cumulocity via its IP either, without using custom DNS entries, as c8y.url doesn't support IP addresses either.

The tedge config set command supports any String value as c8y.url including an IP address. But, you won't be able to connect to c8y with tedge connect or upload the certificate with tedge cert upload etc. These commands will fail to parse the IP address as a URL and fail with errors like this:

Error: failed to connect Cumulocity cloud.

Caused by:
    0: Provided endpoint url is not valid, provide valid url.
       relative URL without a base
    1: relative URL without a base

Describe the solution you'd like

Accept IP addresses as c8y.url and additionally support c8y.http.port and c8y.mqtt.port for HTTP and MQTT ports that may default to 443 and 8883 respectively.

Describe alternatives you've considered

For the c8y.url not accepting IP addresses, a user can create a local DNS entry on the thin-edge device for a dummy domain name pointing to that Cumulocity instance IP. But for different HTTP and MQTT ports, there are no workarounds available.

jarhodes314 commented 1 year ago

Are you sure c8y.url doesn't support IP addresses? I can get/set one using tedge config, and the code explicitly supports it by using url::Host: https://github.com/thin-edge/thin-edge.io/blob/b236aaa11da1934ff808c6ca673ffc9dc591d874/crates/common/tedge_config/src/tedge_config_cli/models/connect_url.rs#L2-L9 Although that may mean the feature isn't well documented?

albinsuresh commented 1 year ago

Well... I should have been clearer. Yes, the tedge config command supports any String value as c8y.url including an IP address. But, you won't be able to connect to c8y with tedge connect or upload the certificate with tedge cert upload etc. These commands will fail to parse the IP address as a URL and fail with errors like this:

Error: failed to connect Cumulocity cloud.

Caused by:
    0: Provided endpoint url is not valid, provide valid url.
       relative URL without a base
    1: relative URL without a base

I've updated the description with this clarification.

reubenmiller commented 11 months ago

This is not a huge priority as you can always just specify a hosts entry in the /etc/hosts file to map a name to an ip address.