HttpTransportSettings.Proxy Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
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 JobClient GetJobClient()
{
try
{
var proxyHost = "localhost";
var proxyPort = 8888;
var transportSettings = new HttpTransportSettings
{
Proxy = new WebProxy(proxyHost, proxyPort)
};
// Specify the WebProxy to be used for the HTTP connection
var jobClient = JobClient.CreateFromConnectionString("a connection string", transportSettings);
return jobClient;
}
catch (Exception)
{
Console.WriteLine("Error creating client.");
throw;
}
}
Remarks
The HttpTransportSettings class is only used for the JobClient or the RegistryManager; so the proxy set here will only be valid for those clients.