IotHubServiceClientOptions.Proxy Property

Definition

The web proxy that will be used to connect to IoT hub 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. IotHubServiceClient GetServiceClient() { var proxy = new WebProxy("localhost", "8888"); var options = new IotHubServiceClientOptions { Protocol = IotHubTransportProtocol.WebSocket, // Specify the WebProxy to be used for the HTTP and web socket connections. Proxy = proxy, // Using the default HttpClient here, so the proxy for HTTP operations will be set for me. }; return new IotHubServiceClient("a connection string", options); }

Remarks

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

Applies to