Share via


IotHubClientTransportSettings.Proxy Property

Definition

The web proxy that will be used to connect to IoT hub using a web socket connection for AMQP, MQTT, or when using the HTTP protocol.

public System.Net.IWebProxy Proxy { get; set; }
member this.Proxy : System.Net.IWebProxy with get, set
Public Property Proxy As IWebProxy

Property Value

Examples

To set a proxy you must instantiate an instance of the WebProxy class--or any class that derives from IWebProxy. The snippet below shows a method that returns a device using a proxy that connects to localhost on port 8888. IotHubDeviceClient GetDeviceClient() { var proxy = new WebProxy("localhost", "8888"); var mqttSettings = new IotHubClientMqttSettings(IotHubClientTransportProtocol.WebSocket) { // Specify the WebProxy to be used for the connection Proxy = proxy, }; var fileUploadSettings = new IotHubClientHttpSettings { // Also configure the proxy for file uploads. Proxy = proxy, }; var options = new IotHubClientOptions(mqttSettings) { FileUploadTransportSettings = fileUploadSettings, }; return new IotHubDeviceClient("a connection string", options); }

Remarks

If you wish to bypass OS-specified proxy settings, set this to GetEmptyWebProxy().

Applies to