I'm trying to run Microsoft Azure device client on Raspberrypi 3 device using below piece of code. when running it in local machine it is working fine, but if I deploy to my raspberry pi 3 device it is throwing "no such host is known. (exception from hresult: 0x80072af9)"
I have windows core IOT 10 os running on my raspberry pi device and using Visual studio 2017 for this sample project. I'm able to run sample apps like helloblinky on my raspberry pi.
private static DeviceClient deviceClient = DeviceClient.Create("<myiothub>.azure-devices.net", new DeviceAuthenticationWithRegistrySymmetricKey(<deviceid>, "<secretkey>"), Microsoft.Azure.Devices.Client.TransportType.Amqp);
while (true)
{
try
{
receivedMessage = await deviceClient.ReceiveAsync();
if (receivedMessage != null)
{
messageData = Encoding.ASCII.GetString(receivedMessage.GetBytes());
await deviceClient.CompleteAsync(receivedMessage);
if (receivedMessage.Properties.ContainsKey("fans"))
{
GpioPinValue change = receivedMessage.Properties["fans"] == "true" ? GpioPinValue.High : GpioPinValue.Low;
pinValue = change;
pin.Write(pinValue);
}
}
}
catch(Exception ex)
{
}
}
User contributions licensed under CC BY-SA 3.0