Closed mtheolog closed 6 years ago
Hi @mtheolog,
There is nothing wrong with your code. The error is most likely caused by a wrong connection string or a network connectivity error.
Here are some tips:
1) Try to copy-paste the connection string from the Azure portal verbatim.
2) Try running it on the device that has stable network connectivity -- for example your dev machine (does not have to be an IoT device like Raspberry Pi).
3) Try changing the transport type in CreateFromConnectionString
from Http1
to Amqp
or Mqtt
. This will not solve the problem but might give a different error message that can give us a clue of what's going on.
@mtheolog - We assume the issue is solved. If that's no the case, please feel free to reopen. Thanks.
Same problem, Almost same code. Not able to solve the problem through the way suggested.
@mtheolog please add more information: what Windows SDK version are you using? Could you please provide network logs following instructions here: https://github.com/dotnet/corefx/blob/master/Documentation/debugging/windows-instructions.md#traces (easiest way is to use the scripts at https://github.com/dotnet/corefx/tree/master/src/Common/tests/Scripts/Tools). Also having a Wireshark trace taken at the same time with the ETW traces would enable us to look at network-level information.
For transient errors you can try the new retry policy: https://github.com/Azure/azure-iot-sdk-csharp/commit/42b32b5dd97aedb10c88feb381318b8d84898995
Thank you for the quick response. I am working on a dragonboard 410c (windows 10 iot core). I enabled the Realtime ETW tracing providing the GUID of the application and caused a deliberate transient error with the scenario I described in my previous post. I did not get any events in the ETW tracing. Logman is not available in windows 10 iot core and I am not sure if I used correctly the ETW tracing. I will have a look at the new retry policy you suggested.
You could be hitting https://github.com/dotnet/corefx/issues/20470. Did you run the UWP application without compiling it using ILC? (Using the F5 / Debug option from Visual Studio instead of using Ctrl+F5 or building a Release version?)
Also, Windows IoT seems to have the xperf tool available: https://docs.microsoft.com/en-us/windows/iot-core/manage-your-device/eventtracing
OK thanks. I will try it.
Please reopen if still having issues.
I have developed an UWP app containing the following method:
private async Task sendToAzure(string message) { try { string DeviceConnectionString = "HostName=XXXXXXX.azure-devices.net;DeviceId=YYYYYYY;SharedAccessKey=ZZZZZZZZZZZZ"; DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(DeviceConnectionString, TransportType.Http1);
}
When the app runs the following exception is thrown:
Exception thrown: 'System.Net.Http.HttpRequestException' in mscorlib.ni.dll Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubCommunicationException' in Microsoft.Azure.Devices.Client.UWP.dll Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubCommunicationException' in mscorlib.ni.dll Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubCommunicationException' in mscorlib.ni.dll Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientTransientException' in Microsoft.Azure.Devices.Client.UWP.dll Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientTransientException' in mscorlib.ni.dll Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientTransientException' in mscorlib.ni.dll Exception thrown: 'Microsoft.Azure.Devices.Client.Exceptions.IotHubClientTransientException' in mscorlib.ni.dll Exception : Transient error occured, please retry.
I would really appreciate any help. Regards, Maria.