Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceClient ReceiveAsync doesn't work with Mqtt, Xamarin Android #249

Closed
FinitelyFailed opened this issue Nov 28, 2017 · 10 comments
Closed
Labels
investigation-required Requires further investigation to root cause this. IoTSDK Tracks all IoT SDK issues across the board xamarin Tracking multiple issues regarding Xamarin applications for Android, iOS and UWP.

Comments

@FinitelyFailed
Copy link

I have tried:
Xamarin.Forms Version 2.5.0.91635, but I have tried every version down to 2.3.
Microsoft.Azure.Devices.Client Version 1.4.0,1.5.0, 1.5.1,1.5.2 and 1.6.0-preview.

Description of the issue:

When I try to receive a message from the IOT-hub I do not get anything when I am using Mqtt, Http1 works fine as well as Amqp.

Code sample exhibiting the issue:

_iotDeviceClient = DeviceClient.CreateFromConnectionString(connectionString, transportType: TransportType.Mqtt);
_iotDeviceClient.ReceiveAsync().ContinueWith(task =>
{
if (!task.IsFaulted)
{
var msg = task.Result;
}
});

When I set a breakpoint on the if-statement and run the code on a device and send a message from the IOT-hub the breakpoint is never triggered. However if I use Http1 or Amqp it triggers. It seems to work fine on iOS and UWP but not on Android. A very few times it triggers but then the task has faulted with a timeout-exception.

@acambitsis
Copy link

Hi there - have you managed to make headway on the above? We are seemingly having the same problem.
Thanks,
Andreas.

@CIPop
Copy link
Member

CIPop commented Jan 17, 2018

Thanks @FinitelyFailed and @acambitsis for reporting this. We didn't get a chance to look into this issue yet.
My understanding was that Xamarin/Android is blocked by #197. Are you able to compile a "Release" version?

@CIPop CIPop added the investigation-required Requires further investigation to root cause this. label Jan 17, 2018
@davidmaiden
Copy link

davidmaiden commented Jan 20, 2018

Hi - I'm having this issue too. Any idea when there will be any progress on this? I'm not sure if its related, but problems I was having with Xamarin/Android and using PackageReference based projects when referencing Microsoft.Azure.Devices.Client (as mentioned in #197) appear to have been solved with the release of VS2017 15.5.4 (yesterday)

@CIPop CIPop self-assigned this Jan 22, 2018
@abhipsaMisra abhipsaMisra self-assigned this May 29, 2018
@nrandell
Copy link

I'm also seeing this. Latest visual studio 15.7.3, latest libraries (Devices.client 1.7.1). Able to build a release mode. AMQP works ok. MQTT just doesn't seem to send or receive.

Here's my sending error - if someone can show me an easy way to get dotnetty logging running, I'm happy to add that as well.

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> DotNetty.Transport.Channels.ClosedChannelException: I/O error occurred.
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.Mqtt.Util+<WriteMessageAsync>d__14.MoveNext () [0x00072] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Devices.Client.Transport.TransportHandler+<>c__DisplayClass3_0.<HandleTimeoutCancellation>b__1 (System.Threading.Tasks.Task t) [0x00031] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
  at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke () [0x00024] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttTransportHandler+<OpenAsync>d__45.MoveNext () [0x00090] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.ProtocolRoutingDelegatingHandler+<TryOpenPrioritizedTransportsAsync>d__3.MoveNext () [0x00168] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.ProtocolRoutingDelegatingHandler+<TryOpenPrioritizedTransportsAsync>d__3.MoveNext () [0x002e5] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.ProtocolRoutingDelegatingHandler+<OpenAsync>d__2.MoveNext () [0x00077] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.Mqtt.Util+<WriteMessageAsync>d__14.MoveNext () [0x00090] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttIotHubAdapter+<Connect>d__32.MoveNext () [0x002bf] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler+<ExecuteWithErrorHandlingAsync>d__20`1[T].MoveNext () [0x0031a] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler+<OpenAsync>d__4.MoveNext () [0x0019c] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler+<OpenAsync>d__23.MoveNext () [0x000b1] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.Azure.Devices.Client.DeviceClient+<>c.<ApplyTimeout>b__74_2 (System.Threading.Tasks.Task t) [0x00013] in <ed298223c75a4d0da4cec9f5b71ac288>:0 
  at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke () [0x00024] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at SceneSkopeKiosk.Iot.IotConnection+<CreateDeviceClientAsync>d__11.MoveNext () [0x000a9] in C:\Users\nick\Source\Repos\SceneSkopeKiosk\SceneSkopeKiosk.Iot\IotConnection.cs:59 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at SceneSkopeKiosk.Iot.IotConnection+<SendString>d__26.MoveNext () [0x0004f] in C:\Users\nick\Source\Repos\SceneSkopeKiosk\SceneSkopeKiosk.Iot\IotConnection.cs:102 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at SceneSkopeKiosk.Services.IotService+<SendNotificationAsync>d__40.MoveNext () [0x00177] in C:\Users\nick\Source\Repos\SceneSkopeKiosk\SceneSkopeKiosk\Services\IotService.cs:192 
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> DotNetty.Transport.Channels.ClosedChannelException: I/O error occurred.
   --- End of inner exception stack trace ---
---> (Inner Exception #0) DotNetty.Transport.Channels.ClosedChannelException: I/O error occurred.<---
<---

@CIPop CIPop removed their assignment Jun 15, 2018
@abhipsaMisra abhipsaMisra removed their assignment Aug 24, 2018
varunpuranik added a commit to varunpuranik/azure-iot-sdk-csharp that referenced this issue Dec 13, 2018
@RubiaL
Copy link

RubiaL commented Oct 10, 2019

Thanks for the feedback.This is currently in our backlog and will consider it as part of our planning cycle

@RubiaL RubiaL closed this as completed Oct 10, 2019
@az-iot-builder-01
Copy link
Contributor

@FinitelyFailed, @acambitsis, @CIPop, @davidmaiden, @nrandell, @RubiaL, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

@RubiaL RubiaL reopened this Oct 10, 2019
@kensykora
Copy link

This is also not working under iOS. Same behavior as the original issue -- ReceiveAsync() never returns any messages, and Sends also throw a TimeoutException .

@sharmasejal sharmasejal added the IoTSDK Tracks all IoT SDK issues across the board label Mar 19, 2020
@abhipsaMisra abhipsaMisra added the xamarin Tracking multiple issues regarding Xamarin applications for Android, iOS and UWP. label May 15, 2020
@vinagesh
Copy link
Member

This issue is really old and seems to be working with the latest SDK and Visual Studio version. We also don't support Xamarin officially yet but if there are any other issues, please feel free to open a new one.

@abhipsaMisra
Copy link
Member

Re-opening and closing to work around dashboard issue.

@abhipsaMisra abhipsaMisra reopened this Jul 1, 2021
@abhipsaMisra
Copy link
Member

Closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigation-required Requires further investigation to root cause this. IoTSDK Tracks all IoT SDK issues across the board xamarin Tracking multiple issues regarding Xamarin applications for Android, iOS and UWP.
Projects
None yet
Development

No branches or pull requests