Comments (8)
We're seeing the same issue. @hotants what version of the SDK are you using?
from azure-iot-sdk-csharp.
Microsoft.Azure.Devices.Client, 1.0.13
Every time, if I called deviceClient.OpenAsync after I created it with SasToken, I did not see the exception any more when sending message.
from azure-iot-sdk-csharp.
Hi hotants,
I will need more information to look into the issue, not getting much out of the stack trace you provided. Were you seeing the same issue previously (prior to 1.0.13). You mentioned that the issue happens around every 200 messages, how do you send the 200 messages? Would you send us your code for that? Thanks.
Regards,
Jasmine
from azure-iot-sdk-csharp.
Investigating !
from azure-iot-sdk-csharp.
I am so sorry not replying in time.
previously we repeated below code for 200 times, to send out 200 messages
_deviceClient = DeviceClient.CreateFromConnectionString(GetConnectionString(), _transportType);
await _deviceClient.OpenAsync();
await _deviceClient.SendEventAsync(message);
await _deviceClient.CloseAsync();
But recently we are not able to reproducing the issue. I have no idea what happens, same environment for test
Thanks
from azure-iot-sdk-csharp.
@hotants - Thank you for the update. Let us know if you're able to repro.
from azure-iot-sdk-csharp.
We are using ServiceBus queues and QueueCient.SendAsync() is throwing:
Cannot access a disposed object. Object name: 'FaultTolerantAmqpObject1'. System.ObjectDisposedException: at Microsoft.Azure.ServiceBus.Core.MessageSender+<OnSendAsync>d__52.MoveNext (Microsoft.Azure.ServiceBus, Version=3.3.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.ServiceBus.RetryPolicy+<RunOperation>d__19.MoveNext (Microsoft.Azure.ServiceBus, Version=3.3.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.ServiceBus.RetryPolicy+<RunOperation>d__19.MoveNext (Microsoft.Azure.ServiceBus, Version=3.3.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.Azure.ServiceBus.Core.MessageSender+<SendAsync>d__39.MoveNext (Microsoft.Azure.ServiceBus, Version=3.3.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Logger.Queue.System.LogQueueSender+<SendInformation>d__2.MoveNext (Logger.Queue, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullLogger.Queue, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: W:\_Logger\Queue\Logger.Queue\System\LogQueueSender.csLogger.Queue, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: 87) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at LoggerCore2ESB.Controllers.ObservationController.ProcessInternalObservation (LoggerCore2ESB, Version=1.0.2.1801, Culture=neutral, PublicKeyToken=nullLoggerCore2ESB, Version=1.0.2.1801, Culture=neutral, PublicKeyToken=null: W:\_Logger\Api\LoggerCore2ESB\Controllers\ObservationController.csLoggerCore2ESB, Version=1.0.2.1801, Culture=neutral, PublicKeyToken=null: 384) at LoggerCore2ESB.Controllers.ObservationController.Internal (LoggerCore2ESB, Version=1.0.2.1801, Culture=neutral, PublicKeyToken=nullLoggerCore2ESB, Version=1.0.2.1801, Culture=neutral, PublicKeyToken=null: W:\_Logger\Api\LoggerCore2ESB\Controllers\ObservationController.csLoggerCore2ESB, Version=1.0.2.1801, Culture=neutral, PublicKeyToken=null: 312) at lambda_method (Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null) at Microsoft.Extensions.Internal.ObjectMethodExecutor+<>c__DisplayClass33_0.<WrapVoidMethod>b__0 (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeActionMethodAsync>d__12.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeNextActionFilterAsync>d__10.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+<InvokeInnerFilterAsync>d__14.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeNextResourceFilter>d__22.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeFilterPipelineAsync>d__17.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker+<InvokeAsync>d__15.MoveNext (Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Builder.RouterMiddleware+<Invoke>d__4.MoveNext (Microsoft.AspNetCore.Routing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware+<Invoke>d__11.MoveNext (Microsoft.AspNetCore.Server.IISIntegration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware+<Invoke>d__3.MoveNext (Microsoft.AspNetCore.Hosting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame
1+d__2.MoveNext (Microsoft.AspNetCore.Server.Kestrel.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
How do we check if the object is available before we try to send? Cannot (at this stage) find a property that exposes a FaultTolerantAmqpObject.
from azure-iot-sdk-csharp.
@timtay-microsoft I am seeing this issue also and it is reproducible for me.
Running the following code
using System.Threading.Tasks;
using Microsoft.Azure.Devices; // version 1.19.0
namespace serviceClientTest
{
class Program
{
private const string iotHubConnectionString = "HostName=kevinsayauto.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=DNiPAREMOVEDClGm4=";
static ServiceClient serviceClient;
static async Task Main(string[] args)
{
serviceClient = ServiceClient.CreateFromConnectionString(iotHubConnectionString, TransportType.Amqp);
await serviceClient.OpenAsync();
Message message = new Message(System.Text.Encoding.UTF8.GetBytes("hello"));
int counter = 0;
while (counter < 10)
{
await serviceClient.SendAsync("demo", message);
counter++;
}
}
}
}
I get the error:
System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'AmqpBodyStreamMessage'.'
after sending 1 message.
If I move the scope of the message to inside the while, I do not get the error. The following code works:
using System.Threading.Tasks;
using Microsoft.Azure.Devices; // version 1.19.0
namespace serviceClientTest
{
class Program
{
private const string iotHubConnectionString = "HostName=kevinsayauto.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=DNiPAREMOVEDGm4=";
static ServiceClient serviceClient;
static async Task Main(string[] args)
{
serviceClient = ServiceClient.CreateFromConnectionString(iotHubConnectionString, TransportType.Amqp);
await serviceClient.OpenAsync();
int counter = 0;
while (counter < 10)
{
Message message = new Message(System.Text.Encoding.UTF8.GetBytes("hello"));
await serviceClient.SendAsync("demo", message);
counter++;
}
serviceClient.CloseAsync();
}
}
}
Is there something I am missing?
OS: Microsoft Windows [Version 10.0.19035.1000]
Visual Studio 2019
.Net Core 3.1
from azure-iot-sdk-csharp.
Related Issues (20)
- Building digital twin of the robotic arm [Technical Question] HOT 2
- How do I send data stored in array (floating type) from my robot to IoT hub? [Technical Question]
- [Bug Report] Fails to establish TPM connection HOT 1
- [Technical Question] Security: Check root certificate on device-to-cloud connection HOT 10
- Unhandled exception. Microsoft.Azure.Devices.Client.Exceptions.IotHubException: Request 817bda7c-6fc4-40e0-8946-93eb851fcb12 returned status 403 [Bug Report] HOT 7
- [Bug Report] Send message in batch to multiple outputs using ModuleClient throws HOT 2
- Is it possible to send bulk messages in telemetry from device to IoT hub? [Technical Question]
- [Technical Question] HttpClientHelper error code 400030 HOT 3
- [Bug Report] When try to fetch reported properties after updating the reported property it will return previous version of reported property not the latest one. HOT 2
- [QUERY] How to properly acknowledge IoT hub messages HOT 6
- [feature request] Make DPS Queries testable HOT 2
- MQTT Channel is Closed / Migrating Sample to .net8 caused an issue HOT 5
- DeviceNotFoundException results in InvalidErrorCode (404103) HOT 2
- [Bug Report] v2.0.0 now removed from nuget package HOT 4
- Getting PlatformNotSupportedException on .NET Framework 4.6.1 HOT 3
- [Technical Question] HOT 1
- [Bug Report] HOT 2
- [Bug Report]Edgehub - Unknown feedback message - HOT 3
- Getting Connection Closed on New Connection Error when it was previously not generated HOT 2
- [Technical Question] Device Update for IoT Hub support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-iot-sdk-csharp.