thin-edge.io icon indicating copy to clipboard operation
thin-edge.io copied to clipboard

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

Open albinsuresh opened this issue 1 year ago • 3 comments

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.

albinsuresh avatar Mar 22 '23 14:03 albinsuresh

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?

jarhodes314 avatar Mar 22 '23 16:03 jarhodes314

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.

albinsuresh avatar Mar 23 '23 02:03 albinsuresh

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.

reubenmiller avatar Nov 07 '23 12:11 reubenmiller