Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
464 stars 493 forks source link

Use gateway hostname from options for connection string flow #3326

Closed abhipsaMisra closed 1 year ago

abhipsaMisra commented 1 year ago

The GatewayHostName set in IotHubClientOptions was being ignored for the connection string flow. This PR updates our SDK to consider this value even when connection strings are used. If a gateway hostname is already specified in the connection string directly, then the value set through options is ignored.

drwill-ms commented 1 year ago

The GatewayHostName set in IotHubClientOptions was being ignored for the connection string flow. This PR updates our SDK to consider this value even when connection strings are used. If a gateway hostname is already specified in the connection string directly, then the value set through options is ignored.

Should the connection string values override client options or the other way around?

abhipsaMisra commented 1 year ago

The GatewayHostName set in IotHubClientOptions was being ignored for the connection string flow. This PR updates our SDK to consider this value even when connection strings are used. If a gateway hostname is already specified in the connection string directly, then the value set through options is ignored.

Should the connection string values override client options or the other way around?

This is the way I see it - the connection string is the most client specific argument, i.e. it is credential specific to this client instance. So, whatever value I specify in there, that should take precedence. So, I might have a "common" options instance in my application that I might want to share across different client instances (with different identities), but the connection string I pass in will be specific to a particular client identity's instance I want to work with.

What do you think?

abhipsaMisra commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
abhipsaMisra commented 1 year ago

I did merge this PR in already, but I synced up with David now and we're going to take it up as a parking lot item as a team for our next scrum. We're going to persist the end resultant behavior, i.e. gateway hostname from client options should be considered even when the client is initialized using a connection string; however, the discussion is open on if the gateway hostname in the client options should take precedence over one in the connection string, or vice versa (for the case where both of them have different gateway hostnames specified).