Code Monkey home page Code Monkey logo

Comments (8)

japf avatar japf commented on July 20, 2024

We're seeing the same issue. @hotants what version of the SDK are you using?

from azure-iot-sdk-csharp.

hotants avatar hotants commented on July 20, 2024

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.

jasmineymlo avatar jasmineymlo commented on July 20, 2024

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.

anhashia avatar anhashia commented on July 20, 2024

Investigating !

from azure-iot-sdk-csharp.

hotants avatar hotants commented on July 20, 2024

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.

tameraw avatar tameraw commented on July 20, 2024

@hotants - Thank you for the update. Let us know if you're able to repro.

from azure-iot-sdk-csharp.

WestieBoy avatar WestieBoy commented on July 20, 2024

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.Frame1+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.

ksaye avatar ksaye commented on July 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.