diff --git a/device/device.go b/device/device.go index 2e61d98..49adc94 100644 --- a/device/device.go +++ b/device/device.go @@ -213,12 +213,7 @@ func (d *Device) Connect(result chan<- error) { } // initialize the client - if err = d.initializeMQTTClient(); err != nil { - if result != nil { - result <- err - } - return - } + d.initializeMQTTClient() // Wait for the token - we're in a coroutine anyway // If AutoReconnect is enabled, reconnections will be handled by diff --git a/device/protocol_mqtt_v1.go b/device/protocol_mqtt_v1.go index c987743..a1d4ab7 100644 --- a/device/protocol_mqtt_v1.go +++ b/device/protocol_mqtt_v1.go @@ -42,7 +42,7 @@ func (d *Device) getBaseTopic() string { return fmt.Sprintf("%s/%s", d.realm, d.deviceID) } -func (d *Device) initializeMQTTClient() error { +func (d *Device) initializeMQTTClient() { opts := mqtt.NewClientOptions() opts.AddBroker(d.brokerURL) opts.SetAutoReconnect(d.opts.AutoReconnect) @@ -55,7 +55,7 @@ func (d *Device) initializeMQTTClient() error { opts.SetStore(s) } - // remove TLS config as it will be handled in the custom connection function + // TLS will be handled in the custom connection function opts.SetCustomOpenConnectionFn(d.astarteCustomOpenConnectionFn) opts.SetOnConnectHandler(func(client mqtt.Client, sessionPresent bool) { @@ -78,8 +78,6 @@ func (d *Device) initializeMQTTClient() error { opts.SetDefaultPublishHandler(d.astarteGoSDKDefaultPublishHandler) d.m = mqtt.NewClient(opts) - - return nil } func (d *Device) astarteGoSDKDefaultPublishHandler(client mqtt.Client, msg mqtt.Message) {