Code Monkey home page Code Monkey logo

Comments (8)

v-tbert avatar v-tbert commented on July 20, 2024

from azure-iot-sdk-csharp.

jeywinlizy avatar jeywinlizy commented on July 20, 2024

Its not executing the break inside. So could that be the cause of cancellation token timing out.

If thats the case how should I solve this.Please let me know.

 if (ct.IsCancellationRequested)
                    break;

I also see that it just comes out of the method and so the return View gets executed.
So after this I am able to see the page. Though I keep a break point at the end of the method - } - it doesn't come there. Looks like it abruptly ends and goes to the called method.
Can we expect any issue in the below statement which is inside the loop.
string data = Encoding.UTF8.GetString(eventData.GetBytes()); --> like a null value or so is being called on - GetBytes or GetString here on eventData --- and it throws error ... or similar?

from azure-iot-sdk-csharp.

jeywinlizy avatar jeywinlizy commented on July 20, 2024

I tried including try catch block
i.e placing the code statements - while(true) part - of the method ReceiveMessagesFromDeviceAsync in try catch block as below.
I have confirmed that it never hits the statements marked below as ====>
STT-A or STT-B or STT-E or STT_END_OF_METHOD
It loops inside while for some number of times (i.e receives data from IoT Hub)
and at one point of time at the statement STT- IoT_DATA it comes out of the method and returns to the calling method - i.e to the method SetHubs() I have mentioned in my query\comment
(This proceeds to display the page)

try{
          if (ct.IsCancellationRequested) 
                break; // STT-A
          EventData eventData = await eventHubReceiver.ReceiveAsync(); // STT- IoT_DATA
          if (eventData == null) 
                 continue;//STT-B
          string data = Encoding.UTF8.GetString(eventData.GetBytes());
}
catch(Expecption exp){
string e =exp.message(); //STT-E
}
} //STT-END_OF_METHOD

Am I missing something like the partition limit or so. If so please guide me how to do or make the required settings to make this work.

## Note : The same code works fine in a Console App.

from azure-iot-sdk-csharp.

serkantkaraca avatar serkantkaraca commented on July 20, 2024

I would like to know why you commented out Task.WaitAll ?

//Task.WaitAll(tasks.ToArray());

from azure-iot-sdk-csharp.

jeywinlizy avatar jeywinlizy commented on July 20, 2024

In this web app, If that is not commented the system hangs - continuously waits - there ;
even when I'm debugging the debugger doesn't get back if that statement is hit.

When this statement(Task.WaitAll(tasks.ToArray());) is in a Console App the control(or debugger) continuously loops thro while\foreach loop
until a break given.

from azure-iot-sdk-csharp.

serkantkaraca avatar serkantkaraca commented on July 20, 2024

I don't think you can fire and forget async receivers this way. You need to have a background task manager to root client objects and tasks. For example, what happens when eventHubClient is garbage collected while your receiver is still running. Can you dig into web for correct implementation of "fire and forget" programming in ASPNet applications?

from azure-iot-sdk-csharp.

olivierbloch avatar olivierbloch commented on July 20, 2024

Hi @jeywinlizy
I think the conversation has now gone way beyond the SDK use itself. Would it be possible for you to post the issue you are having on StackOverflow to make sure you get the right people looking into it?
Thanks

from azure-iot-sdk-csharp.

tameraw avatar tameraw commented on July 20, 2024

@jeywinlizy - Since this issue is not related particularly to this SDK, we're closing it here.

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.