ServiceClientTransportSettings.AmqpProxy Property

Definition

The web proxy that will be used to connect to IoT hub when using the AMQP over web sockets.

public System.Net.IWebProxy AmqpProxy { get; set; }
member this.AmqpProxy : System.Net.IWebProxy with get, set
Public Property AmqpProxy 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 }; 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

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 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. This setting is to be used in conjunction with the HttpProxy property.

Applies to