Azure / azure-iot-protocol-gateway

Azure IoT protocol gateway enables protocol translation for Azure IoT Hub
Other
225 stars 151 forks source link

Old references to Device Drivers giving issues #125

Closed mohammednaseem closed 5 years ago

mohammednaseem commented 6 years ago

I have added Device Twin trigger. await client.SetDesiredPropertyUpdateCallbackAsync(iHc.OnDesiredPropertyChanged, null);

see below

` public static async Task CreateFromConnectionStringAsync(string deviceId, string connectionString, int connectionPoolSize, TimeSpan? connectionIdleTimeout, IotHubClientSettings settings, IByteBufferAllocator allocator, IMessageAddressConverter messageAddressConverter) { int maxPendingOutboundMessages = settings.MaxPendingOutboundMessages; var tcpSettings = new AmqpTransportSettings(TransportType.Amqp_Tcp_Only); var webSocketSettings = new AmqpTransportSettings(TransportType.Amqp_WebSocket_Only); webSocketSettings.PrefetchCount = tcpSettings.PrefetchCount = (uint)maxPendingOutboundMessages; if (connectionPoolSize > 0) { var amqpConnectionPoolSettings = new AmqpConnectionPoolSettings { MaxPoolSize = unchecked ((uint)connectionPoolSize), Pooling = connectionPoolSize > 0 }; if (connectionIdleTimeout.HasValue) { amqpConnectionPoolSettings.ConnectionIdleTimeout = connectionIdleTimeout.Value; } tcpSettings.AmqpConnectionPoolSettings = amqpConnectionPoolSettings; webSocketSettings.AmqpConnectionPoolSettings = amqpConnectionPoolSettings; } DeviceClient client = DeviceClient.CreateFromConnectionString(connectionString, new ITransportSettings[] { tcpSettings, webSocketSettings });

        IotHubClient iHc = new IotHubClient(client, deviceId, settings, allocator, messageAddressConverter);

        try
        {
            await client.OpenAsync();
            await client.SetDesiredPropertyUpdateCallbackAsync(iHc.OnDesiredPropertyChanged, null);  
        }
        catch (IotHubException ex)
        {
            throw ComposeIotHubCommunicationException(ex);
        }

        return iHc;
    }

But it started throwing the below issues. https://github.com/Azure/azure-iot-sdk-c/issues/210 "Device Twin over AMQP failure: The link address did not match any of the expected formats". I updated the reference within the protocol gateway to the latest version within the ProtocolGateway.IotHubClient.NetStandard.csproj<PackageReference` Include="Microsoft.Azure.Devices.Client" Version="1.18.0" /> and the errors went away.