ITransportSettings.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

An instance of a class that implements IWebProxy.

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. static DeviceClient GetClientWithProxy() { try { var proxyHost = "localhost"; var proxyPort = 8888; // Specify the WebProxy to be used for the web socket connection var transportSettings = new AmqpTransportSettings(Microsoft.Azure.Devices.Client.TransportType.Amqp_WebSocket_Only) { Proxy = new WebProxy(proxyHost, proxyPort) }; var deviceClient = DeviceClient.CreateFromConnectionString("a connection string", new ITransportSettings[] { transportSettings }); return deviceClient; } catch (Exception) { Console.WriteLine("Error creating client."); throw; } }

Remarks

This setting will be used when the client attempts to connect over web sockets. For example, if the client attempts to connect to IoT hub using Amqp or Mqtt the client will first try over TCP. If that fails, the client will fall back to using web sockets and will use the proxy setting. The setting will also be used when Amqp_WebSocket_Only, Mqtt_WebSocket_Only, or Http1 is specified.

Applies to