Giter VIP home page Giter VIP logo

Comments (6)

minzdrav avatar minzdrav commented on September 26, 2024 1

Hey @minzdrav, just wondering if that worked for you? Did you manage to run a client per thread without issue?

Hi @MatthijsvdVeer
Yes.

from bacnet.

YarekTyshchenko avatar YarekTyshchenko commented on September 26, 2024 1

Yup, can confirm the reads are not threadsafe. It has to do with InvokeId, a uint8 that gets added to every request like a correlation ID, it gets incremented every request, and if you send too many requests it can quickly roll over and cause problems.

Update: On further investigation the reads cause a thread to be blocked waiting for reply because of the use of ManualResetEvent, this is actually a much bigger problem, as the non thread-safe client can be wrapped in a mutex, and multiple clients started in parallel, however, the reads will quickly eat up worker threads.

Fortunately a solution could be to replace ManualResetEvent with a TaskCompletionSource which doesn't block a thread. The rest of the code seems to be non-blocking which is great.

from bacnet.

minzdrav avatar minzdrav commented on September 26, 2024

Hi Guys,
I have same problem with https://github.com/ela-compil/BACnet/tree/v2-netstandard brunch.
Could you please try to fix?

from bacnet.

gralin avatar gralin commented on September 26, 2024

Unfortunatelly the client was not written to be thread safe. Try using a lock each time before you use it or write a wrapper that would do it for you for each atomic operation. Since BACnet operations have identifiers it should be possible to allow multiple requests to be sent out in the same time. I will leave this issue open to try to address it in the future.

from bacnet.

minzdrav avatar minzdrav commented on September 26, 2024

Hi @gralin
Thank you.
Yes, it's working fine with locks.
I have 1 thread per device and customer want to read properties and values from many devices. I'll try to create BACnet client per thread. Should work faster than locks.

from bacnet.

MatthijsvdVeer avatar MatthijsvdVeer commented on September 26, 2024

Hey @minzdrav, just wondering if that worked for you? Did you manage to run a client per thread without issue?

from bacnet.

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.