IAM이 IOThub에 메시지를 보내고 응답을 받으려고 시도하는 간단한 애플 리케이션을 만들려고 시도했지만 아무 일도 일어나지 않습니다.IOT 허브가 메시지를 보내지 않거나 전송하지 않습니다.
장치 컨트롤러에서 연결 고리를 복사했습니다. Ofcource 나는이 질문을 위해 그것을 숨겼다.
메시지가 성공적으로 발송되었음을 알았지 만, iothub를 확인할 때 0 개의 수신 된 메시지가 표시됩니다.
iothub의 무료 티어를 사용하는 Iam이 제한 사항입니까?
public sealed partial class MainPage : Page
{
private const string DeviceConnectionString = "Hidden";
private readonly DeviceClient _deviceClient;
public MainPage()
{
this.InitializeComponent();
_deviceClient = DeviceClient.CreateFromConnectionString(DeviceConnectionString, TransportType.Amqp); //Already tried using different transport types but no succes.
}
public async Task SendEvent()
{
Debug.WriteLine("\t{0}> Sending message", DateTime.Now.ToLocalTime());
var commandMessage = new Message(Encoding.ASCII.GetBytes("Cloud to device message."));
await _deviceClient.SendEventAsync(commandMessage);
Debug.WriteLine("Succesfully sended message to IotHub");
}
public async Task ReceiveCommands()
{
Debug.WriteLine("\nDevice waiting for commands from IoTHub...\n");
while (true)
{
var receivedMessage = await _deviceClient.ReceiveAsync();
if (receivedMessage != null)
{
var messageData = Encoding.ASCII.GetString(receivedMessage.GetBytes());
Debug.WriteLine("\t{0}> Received message: {1}", DateTime.Now.ToLocalTime(), messageData);
var propCount = 0;
foreach (var prop in receivedMessage.Properties)
{
Debug.WriteLine("\t\tProperty[{0}> Key={1} : Value={2}", propCount++, prop.Key, prop.Value);
}
await _deviceClient.CompleteAsync(receivedMessage);
Debug.WriteLine("Finishing recieving message");
}
await Task.Delay(TimeSpan.FromSeconds(1));
}
}
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
Debug.WriteLine("Sending event");
await SendEvent();
await ReceiveCommands();
Debug.WriteLine("Received commands");
}
}
[장치 탐색기]에서 보낸 D2C 메시지를 볼 수 있습니까 (https://github.com/Azure/azure-iot-sdk-csharp/tree/master/tools/DeviceExplorer#run-the-sample- 신청)? –
예 : 수신 중 이벤트 수신 중 ... 2017-04-10 20:08:53> 기기 : [RaspberryPI], 데이터 : [기기 대결 메시지] – Barsonax
글쎄, 내가 무슨 말을하는거야? 받은 메시지가 0 개 있습니다. " 이 D2C 메시지를 받기 위해'ReceiveCommands()'를 사용한다는 뜻입니까? –