ServiceClientTransportSettings.HttpProxy Property

Definition

The web proxy that will be used to connect to IoT hub when operations must execute over HTTP.

public System.Net.IWebProxy HttpProxy { get; set; }
member this.HttpProxy : System.Net.IWebProxy with get, set
Public Property HttpProxy 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 ServiceClient GetServiceClient() { try { var proxyHost = "localhost"; var proxyPort = 8888; var proxy = new WebProxy(proxyHost, proxyPort); var transportSettings = new ServiceClientTransportSettings { AmqpProxy = proxy, HttpProxy = proxy }; // Specify the WebProxy to be used for the web socket connection var serviceClient = ServiceClient.CreateFromConnectionString("a connection string", Microsoft.Azure.Devices.TransportType.Amqp_WebSocket_Only, transportSettings ); return serviceClient; } catch (Exception) { Console.WriteLine("Error creating client."); throw; } }

Remarks

Methods such as GetServiceStatisticsAsync(CancellationToken) are executed over HTTP and not AMQP. This setting will ensure those methods are executed over the specified proxy. This setting is to be used in conjunction with the AmqpProxy property.

Applies to