Partager via


IotHubClientTransportSettings.Proxy Propriété

Définition

Proxy web qui sera utilisé pour se connecter à IoT Hub à l’aide d’une connexion de socket web pour AMQP, MQTT ou lors de l’utilisation du protocole HTTP.

public System.Net.IWebProxy Proxy { get; set; }
member this.Proxy : System.Net.IWebProxy with get, set
Public Property Proxy As IWebProxy

Valeur de propriété

Exemples

Pour définir un proxy, vous devez instancier un instance de la WebProxy classe ou de toute classe dérivée de IWebProxy. L’extrait de code ci-dessous montre une méthode qui retourne un appareil à l’aide d’un proxy qui se connecte à localhost sur le port 8888. IotHubDeviceClient GetDeviceClient() { var proxy = new WebProxy("localhost", "8888"); var mqttSettings = new IotHubClientMqttSettings(IotHubClientTransportProtocol.WebSocket) { // Specify the WebProxy to be used for the connection Proxy = proxy, }; var fileUploadSettings = new IotHubClientHttpSettings { // Also configure the proxy for file uploads. Proxy = proxy, }; var options = new IotHubClientOptions(mqttSettings) { FileUploadTransportSettings = fileUploadSettings, }; return new IotHubDeviceClient("a connection string", options); }

Remarques

Si vous souhaitez ignorer les paramètres de proxy spécifiés par le système d’exploitation, définissez cette valeur sur GetEmptyWebProxy().

S’applique à